Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi team,
I have 12 textboxes in my asp.net page(.aspx),and i want to validate them before they all are submitted.
I can use RequiredValidation for all textboxes but it looks very wierd,so i need a common validation for all the textboxes i.e whenever any textbox is left empty i should get an error message and error focus should be on that particular textbox.

Please team help me to achieve this.
Your assistance will be highly appreciated..
Posted
Comments
JoCodes 28-Nov-13 6:35am    
Why validation controls with validation group and validation summary is not preferred here? Otherwise you need to do it clientside using JQuery
[no name] 28-Nov-13 6:57am    
would you plz give me a sample of that JQuery?

1 solution

add a class named required in all textboxes
use jquery to validate

C#
$("input.required ").each(function(){
    if($.trim($(this).val()) == ""){
//       warning message
    }
});
 
Share this answer
 
Comments
[no name] 28-Nov-13 5:37am    
I dont know JQuery,would you plz give me another option?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900