Call Now
+1-908-873-6465
+44-20351-45403
Support

Form validation using Parsley

Form validation normally used to occur at the server, after the client had entered all the necessary data and then pressed the Submit button. If the data entered by a client is incorrect or is simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information. This is really a lengthy process which used to put a lot of burden on the server.

That expalins the client end form validation using Javascript.

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 !

Last modified on Tuesday, 28 June 2016 19:12