Last active
December 20, 2015 07:39
-
-
Save imknight/6094510 to your computer and use it in GitHub Desktop.
custom function for Parsley before submit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#contactform').parsley({ | |
//exclude input type , file ? | |
excluded: 'input[type=hidden]', | |
validators: { | |
// for #3 ,checking the input must have value , example dropdown list with "Select this" kind of option should be no value so that it can be skipped | |
checkdefault: function (val, checkdefault) { | |
if (val[0] === '') return false; | |
else return true; | |
} | |
}, | |
messages: { | |
checkdefault: "This value should be a multiple of %s" | |
}, | |
listeners: { | |
onFieldValidate: function (elem) { | |
//for #2 ,checking and make sure the parent div is not hidden | |
if (elem.parents('div.ishidden:eq(0)').length > 0 && !elem.parents('div.ishidden:eq(0)').is(':visible')) { | |
return true; | |
} | |
return false; | |
}, | |
onFormSubmit: function (isFormValid, event, focusedField) {}, | |
onFieldError: function (elem, constraint) {} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment