Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

RequiredFieldValidator issue

Posted on 2014-03-26
6
202 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
ID: 39955706
Validation summary control near to the submit button
0
 

Author Comment

by:RTKHOT
ID: 39955721
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
ID: 39955762
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:RTKHOT
ID: 39955790
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
ID: 39955818
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
ID: 39958124
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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