The 'required' attribute isn't supported/respected across all browsers, so this plugin should help with validation.
Run bower install jq.required.validate
from within your project directory.
Run git clone https://github.com/mykehowells/jq.required.validate.git
from within your project directory.
Download the latest release of this repository from here and move into your project directory.
$( 'form' ).on( 'submit', function ( e ) {
// Get the form object.
var form = $(this);
// Pass form to Validator.validate() object function.
var Validation = Validator.validate( form );
// Remove any failed validation classes from required fields, ready for next validation check.
Validation.clear();
// Check if validation has failed.
if( Validation.failed() ) {
// Mark failed fields.
Validation.mark();
// Return false to halt script execution.
return false;
}
// Continue processing...
}