Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

RequiredFieldValidator issue

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
RTKHOT
Asked:
RTKHOT
  • 3
  • 2
1 Solution
 
jayakrishnabhCommented:
Validation summary control near to the submit button
0
 
RTKHOTAuthor Commented:
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
 
jayakrishnabhCommented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
RTKHOTAuthor Commented:
and how do i check if any one validation has failed? does the validator control return anything that i can check?
0
 
jayakrishnabhCommented:
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
 
Alan WarrenApplications DeveloperCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now