Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to validate textbox,checkbox,dropdownlist for dynmically added controls on button click

using onblur..is there any way, so that i achieve it.

Example:

1>If textbox,checkbox,dropdownlist should not empty --provide error msg
2>If checkbox should be checked and dropdownlist values should have selected value--if not error msg.
3>If checkbox should be checked ,dropdownlist should have selected index,textbox could not blank



In my gridview there are more than 1oo rows so there many possibility can occur 123,321,12,13,31 ....

So thats why i want to implement validation onblur,so wherever condition get false it will prompt with error msg..

Please help me how can i achieve it...

Thanks
Posted
Updated 11-Jun-14 21:07pm
v3

try this demo.. :)

Javascript

JavaScript
function validateControl(value)
       {

           if (value == "")
           {

               alert("This field can not be blank..!!");
           }
       }


HTML

HTML
<input type="text" id="txtUserName" onblur="validateControl(this.value)"/ >
 
Share this answer
 
Attach onblur event to every control, while they are created dynamically.
Then in that onblur JavaScript event, fetch the control and validate.
 
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