
JQuery is a javascript library and widely used on the websites as it provides most of the functionalities with just few lines of code. It is also compatible to legacy browser as well.Â
Step 1:
Place the javascript files within the head section
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js</script>
<script>
$(document).ready(function(){
 $("#registerForm").validate();
});
</script>
</head>
You should set the name and id of your html form same as $(â#registerFormâ).validate();
Step 2:
For each required form element just place class=ârequiredâ and specify minlength tag inside it. For example
Name field -> class=âoptionalâ
Email field -> class = ârequired emailâ
Sample Code:
Thats it! you will be able to validate form field textboxes without any advanced code.
For optional fields, you can specify class=âoptionalâ or just leave it.
Here is the playable code editor where you can test the validation!