Form validation is very important, we will use textboxs in many places. we have to do client side validation using javascript. I am showing one example here. After click on button, if textbox value is empty. this will show alert "please enter name".
If you have any queries or suggestions, please feel free to ask in comments section.
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function ValidateForm() { var txtName = document.getElementById("txtName").value; if (txtName == '') alert("please enter name"); } </script> </head> <body> Name: <input type="text" id="txtName" /><br /> <br /> <input type='button' value="validate" onclick="ValidateForm();" /> </body> </html>
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.