Parsley is a javascript form validation library. This snippets configures parsley for bootstrap input elements.

var parsleyInstance = $('#checkout').parsley({
    errorClass: 'has-error',
    successClass: 'has-success',
    errorsWrapper: '<div></div>',
    errorTemplate: '<span class="help-block"></span>',
    classHandler: function (ParsleyField) {
        return ParsleyField.$element.parent();
    }
});

parsley options reference: http://parsleyjs.org/doc/annotated-source/defaults.html

Categories: JavaScript