JS Validation


The JS Validation module is used for setting up front-end <form> validation.

At the time of writing, we use a jQuery plugin called jQuery Validation to perform client-side form validation. Please refer to their documentation for options to the validate() method.


All <form>s to be initialized must be given the class js-validate.

All jQuery Validate initialization code should live inside ValidationHandler.init(). This method provides a default settings object that can be partially or entirely overridden using switch cases.

Different validation types should be designated using the data-validation-type attribute. This is to prevent a <form> from having more than one type of validation.



Required select

In order to make a select element required, its first and default option must have the empty string as its value (value=""), in addition to the select element having the required attribute.