Solved

RequiredFieldValidator issue

Posted on 2014-03-26
6
204 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
[X]
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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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