-
-
Save dnszero/f74d34c79f18434afcaf to your computer and use it in GitHub Desktop.
Parsley config for twitter bootstrap 3.x
This file contains hidden or 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
$.fn.parsley.defaults = | |
# basic data-api overridable properties here.. | |
inputs: "input, textarea, select" # Default supported inputs. | |
excluded: "input[type=hidden], :disabled" # Do not validate input[type=hidden] & :disabled. | |
trigger: false # $.Event() that will trigger validation. eg: keyup, change.. | |
animate: true # fade in / fade out error messages | |
animateDuration: 300 # fadein/fadout ms time | |
focus: "first" # 'fist'|'last'|'none' error field to focus after validation | |
validationMinlength: 3 # Min Length for triggered validation | |
successClass: "has-success" # Class name on each valid input | |
errorClass: "has-error" # Class name on each invalid input | |
errorMessage: false # Customize an unique error message showed if one constraint fails | |
validators: {} # Add your custom validators functions | |
showErrors: true # Set to false if you don't want Parsley to display error messages | |
messages: {} # Add your own error messages here | |
#some quite advanced configuration here.. | |
validateIfUnchanged: false # false: validate once by field value change | |
errors: | |
classHandler: (elem, isRadioOrCheckbox) -> | |
# specify where parsley error-success classes are set | |
$(elem).parents ".form-group" | |
container: (elem, isRadioOrCheckbox) -> | |
errorsWrapper: "<span class=\"help-block\"></span>" # do not set an id for this elem, it will have an auto-generated id | |
errorElem: "<span></span>" # each field constraint fail in an li | |
listeners: | |
onFieldValidate: (elem, ParsleyForm) -> | |
# Executed on validation. Return true to ignore field validation | |
false | |
onFormSubmit: (isFormValid, event, ParsleyForm) -> | |
# Executed once on form validation | |
onFieldError: (elem, constraints, ParsleyField) -> | |
# Executed when a field is detected as invalid | |
onFieldSuccess: (elem, constraints, ParsleyField) -> | |
# Executed when a field passes validation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment