Parsley: Field Cheat Sheet

Options

Set a specific field value for Parsley validation, dissociated from the real one:

data-parsley-value

Assign a group to a field for specific group validation:

data-parsley-group

Add this attribute to radio / checkboxes elements:

data-parsley-multiple

A field is by default not validated if it is not required and empty:

data-parsley-validate-if-empty 

Perform actions on whitespace in value (only for Parsley validation):

data-parsley-whitespace

Add parsley-success and parsley-error classes on field, but no error message:

data-parsley-errors-messages-disabled

Postpones validation for a given number of milliseconds after user input has stopped arriving:

data-parsley-debounce

Methods

MethodReturnsDescription
isValid({force}) true if all ok
null if some validations are still pending
[Violation, ...]] if fails
Returns if the field is valid or not. Does not affect UI nor fires events. If force is set, it forces validation even on non-required fields
validate({force, group}) true if all ok
null if some validations are still pending
[Violation, ...]] if fails
Validate Field. Fires events and affects UI. If force is set, force validate even non required fields
getErrorsMessages() arrayReturns an array of field’s error messages
reset() Reset UI for this field.
destroy() Disable and destroy Parsley for this field.

Leave a Reply

Your email address will not be published. Required fields are marked *