Click here to Skip to main content
15,914,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my application I have a name field (txtname), username field(txtusername),etc. I have inserted a required field validations for both, the required field validator is working fine when we click on the button(submit). But here my requirement is, if the user not enter the previous field (means he left blank of txtname and entering the data for next field say txtusername), at that time it has to immediately through an error message (like "You can't leave this empty."). Like in gmail create account this idea is used. Like wise i want do the same. Please help me out regarding this.

Sorry for any errors or not understanding.
Posted

Hi,
You need to use JavaScript validation to show the alert box. Follow the links below to perform validation using JavaScript:
http://www.w3schools.com/js/js_form_validation.asp[^]
http://www.javascript-coder.com/html-form/javascript-form-validation.phtml[^]
http://www.tizag.com/javascriptT/javascriptform.php[^]

All the best.
--Amit
 
Share this answer
 
You have to set causesvalidation=true for the controls. So that when you move focus from one control to other, it will validate previous controls.
 
Share this answer
 

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