Solved

RequiredFieldValidator issue

Posted on 2014-03-26
6
198 Views
Last Modified: 2014-03-26
My web page has an online form with about 40 textbox fields placed one below the other. Each textbox has a RequiredFieldValidator attached to it which gives an error if the textbox is left empty.

Everything is working well. But the problem is that the submit button is at the bottom. If the user has left some textbox empty on the top, then the submit click wont work, but the user will not know since the textbox giving error is on top.

Is there anyway i can catch if any of the validators has given an error, then i could show a message near the submit button that some field above has been left empty.
0
Comment
Question by:RTKHOT
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:jayakrishnabh
Comment Utility
Validation summary control near to the submit button
0
 

Author Comment

by:RTKHOT
Comment Utility
No. That give the error message of each field. I just want a common message such as "Please check all above items".

Validation summary gives the error message of each field. if the client has left all 40 textboxes empty, it will be a problem
0
 
LVL 5

Expert Comment

by:jayakrishnabh
Comment Utility
OnClientClick call javascript function and set the common message of the error message holder near submit button if atleast one of the validation fails.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:RTKHOT
Comment Utility
and how do i check if any one validation has failed? does the validator control return anything that i can check?
0
 
LVL 5

Expert Comment

by:jayakrishnabh
Comment Utility
Not through the validator, but from Textboxe's values as follows

if (document.getElementById("TextBox1").value.trim().length == 0 || document.getElementById("TextBox2").value.trim().length == 0
                || document.getElementById("TextBox3").value.trim().length == 0) {
                //Set the message here
            }
            return false;
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 200 total points
Comment Utility
Hi RTKHOT,

Try setting the SetFocusOnError property of the RequiredFieldValidator control to True, default value is False. Then the user won't need to scroll up to find the error because focus will shift to the first control that failed validation in the specified validation group.

BaseValidator.SetFocusOnError Property
Gets or sets a value that indicates whether focus is set to the control specified by the ControlToValidate property when validation fails.

Respectfully yours,
Alan
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now