Options
Property | Default | Description |
---|---|---|
data-parsley-namespace | data-parsley- | Choose the DOM-API you want to use for Parsley. |
data-parsley-validate | Bind Parsley validation to the form and its items with validation constraints | |
data-parsley-priority-enabled | true | Either validate higher priority constraints first and stop on first failure (true ), or validate all constraints simultaneously and show all the failing ones (false ). |
data-parsley-inputs | input, textarea, select | When looking for fields within a form, Parsley uses this selector. The fields found will then be filtered using the excluded option below. |
data-parsley-excluded | input[type=button], input[type=submit], input[type=reset], input[type=hidden] | Form fields that won’t be validated by Parsley. |
parsley-use-html5-constraints | true | Bind or not supported HTML5 tags |
parsley-show-errors | true | Choose to show or not Parsley error messages & success / errors classes |
parsley-focus | first | Specify which field will be focused first on form validation errors. first , last and none allowed |
Methods
Method | Returns | Description |
---|---|---|
whenValid({group, force}) | promise | Returns a jQuery promise that will be fulfilled if and only if the Form is valid. Does not affect UI nor fires events. |
isValid({group, force}) | boolean or null | Similar to whenValid but returns true if the promise is already fulfilled, false if already rejected, and null if the validation is still pending. |
whenValidate({group, force}) | promise | Validate form. Prevents submission if not valid. Fires events and affects UI. You can only validate a certain group of fields by specifying optional group string parameter. If group is given, it only validates fields that belong to this group. |
validate({group, force}) | boolean or null | Same as whenValidate except it returns true if the promise is already fulfilled, false if already rejected, and null if the validation is still pending. |
refresh() | Forces a refresh of the form and its field. Parsley always refreshes before validation, but this may be helpful for dynamic changes that need to be applied immediately | |
reset() | Reset UI for this form and for its fields. | |
destroy() | Disable and destroy Parsley for this form and its fields |