The Validators() function is the main interface to the library, the first argument is an object that contains a mapping between the selectors(css or xpath) of the form fields and their corresponding Validator objects. To use multiple selectors, separate the selectors with a comma. The second argument is a callback function which is called if form validation is success, insert any code that you may want to call before form submission or if you want to submit the form by ajax.
If you want to use the ‘submit’ input type in the form, use jQuery’s .submit() function like this:
You can also create your own validators either by extending the classes defined in the Coffeescript source or in the following ways:
- By providing a function that performs an operation on the field value and returns a true or a false value based on the validation success.
- By providing a regular expression to match with.
You can find the coffeescript source and documentation over here.