There are plenty of powerful jQuery validation plugins out there to meet your needs, but sometimes your requirement is so little that you just don’t bother including these plugins into your page, you might just create your own simple validation for your Form. So here’s a simple jQuery validation script you can include in your form page and have almost powerful validation.
Let’s say you have similar HTML form as below, which needs validation.
Here’s simple jQuery validation script, which will loop though each Form field that has required=”true” attribute and validate them. If field is empty or email is incorrect, it will simply change field border color to red, and when user types again the color will change back to normal.
Here’s the demo of simple jQuery validation script.