JavaScript provides a way to validate form's data on the client's computer before sending it to the web server. Form validation generally performs two functions.
1. The form must be checked to make sure all the mandatory fields are filled in.
2. The data that is entered must be checked for correct form and value. E.g. valid email or valid Phone numbers.
However, Javascript form validation does not replace strong backend server validation.
Now, to do the validation, we need to right down the same validation code again and again and also do testing. Too much time consuming stuff but still needs to be done on each form.
That's why Parsley is here: to let you define your general form validation, implement it on the backend side, and simply port it frontend-side, with maximum respect to user experience best practices.
Parsley is a javascript form validation library
Please download the parsley.min.js from http://parsleyjs.org/dist/parsley.min.js
and include it in header with any jquery.js.
<script src="/jquery.js"></script>
<script src="/parsley.min.js"></script>
and copy css from http://parsleyjs.org/src/parsley.css to your style.css
Thats it !
Read documentation here and make form validation in few minutes and that too using industry standard and very well tested code.
http://parsleyjs.org/doc/index.html#psly-frontend-form-validation
Happy validation !