Validating a form in javascript

6854933580_2c8b688306_z

It relies heavily on configuration over convention and as a result can easily be integrated into existing projects.JS Form Validator is javascript framework agnostic. To use JS Form Validator, you need to include the script on the page, define the validation rules and callback functions, and finally tell the validator when to run validation. They can either be set globally (see below) or passed in when creating the Form Validator object.

See the Pen Form Validation: The Mail Chimp Simple Signup Form by Chris Ferdinandi (@cferdinandi) on Code Pen.Now, let's take what we've learned and apply it to a real example: the Mail Chimp signup form.When you embed a Mail Chimp signup form on your site, it comes with a Java Script validation script named `mc-validate.js`.It will work fine without a framework and can also take advantage of Moo Tools, j Query, etc. This is a callback function that is called when a field fails validation.It takes the field and an error message as arguments.The keys are field identifiers and the values are objects containing a 'field' and 'validate' parameter.

You must have an account to comment. Please register or login here!