API Docs for:
Show:

ParsleyField Class

Defined in: parsley.js:310

ParsleyField class manage each form field inside a validated Parsley form. Returns if field valid or not depending on its value and constraints Manage field error display and behavior, event triggers and more

Constructor

ParsleyField

()

Defined in parsley.js:310

Methods

addConstraint

(
  • constraint
)

Defined in parsley.js:432

Dynamically add a new constraint to a field

Parameters:

  • constraint Object

    { name: requirements }

addConstraints

() private

Defined in parsley.js:418

Attach field validators functions passed through data-api

addCustomConstraintMessage

(
  • constraint
)
private

Defined in parsley.js:524

Add custom constraint message, passed through data-API

Parameters:

  • constraint Object

addError

(
  • {
)

Defined in parsley.js:819

Add li error

Parameters:

  • { Object

    minlength: "error message for minlength constraint" }

applyValidators

() Mixed

Defined in parsley.js:722

Loop through every fields validators Adds errors after unvalid fields

Returns:

Mixed:

{Boolean} If field valid or not, null if not validated

bindHtml5Constraints

() private

Defined in parsley.js:381

Bind some extra html5 types / validators

bindValidationEvents

() private

Defined in parsley.js:542

Bind validation events on a field

destroy

() private

Defined in parsley.js:924

Destroy parsley field instance

eventValidation

(
  • event
)

Defined in parsley.js:607

Called when validation is triggered by an event Do nothing if val.length < this.options.validationMinlength

Parameters:

  • event Object

    jQuery event

generateHash

() String

Defined in parsley.js:576

Hash management. Used for ul error

Returns:

String:

5 letters unique hash

getHash

() String

Defined in parsley.js:586

Public getHash accessor

Returns:

String:

hash

getLength

() Int

Defined in parsley.js:635

Get the length of a given value

Returns:

Int:

The length of the value

getVal

() String

Defined in parsley.js:596

Returns field val needed for validation Special treatment for radio & checkboxes

Returns:

String:

val

hasConstraints

() Boolean

Defined in parsley.js:656

Return if field has constraints

Returns:

Boolean:

Is field has constraints or not

init

(
  • element
  • options
)

Defined in parsley.js:334

Set some properties, bind constraint validators and validation events

Parameters:

  • element Object
  • options Object

isValid

() Boolean

Defined in parsley.js:646

Return if field verify its constraints

Returns:

Boolean:

Is field valid or not

manageError

(
  • constraint
)

Defined in parsley.js:860

Add li / ul errors messages

Parameters:

  • constraint Object

manageErrorContainer

()

Defined in parsley.js:896

Create ul error container

manageValidationResult

() Boolean

Defined in parsley.js:749

Fired when all validators have be executed Returns true or false if field is valid or not Display errors messages below failed fields Adds parsley-success or parsley-error class on fields

Returns:

Boolean:

Is field valid or not

needsValidation

(
  • value
)
Boolean

Defined in parsley.js:706

Check if value has changed since previous validation

Parameters:

  • value Object

Returns:

Boolean:

removeConstraint

(
  • constraintName
)

Defined in parsley.js:494

Dynamically remove an existing constraint to a field.

Parameters:

  • constraintName String

removeError

(
  • constraintName
)

Defined in parsley.js:801

Remove li / ul error

Parameters:

  • constraintName String

    Method Name

removeErrors

()

Defined in parsley.js:833

Remove all ul / li errors

reset

()

Defined in parsley.js:842

Remove ul errors and parsley error or success classes

ulErrorManagement

() private

Defined in parsley.js:790

Manage ul error Container

updtConstraint

(
  • constraint
)

Defined in parsley.js:463

Dynamically update an existing constraint to a field. Simple API: { name: requirements }

Parameters:

  • constraint Object

updtConstraint

(
  • constraint
)

Defined in parsley.js:476

Dynamically update an existing constraint to a field. Complex API: { name: name, requirements: requirements, valid: boolean }

Parameters:

  • constraint Object

validate

(
  • errorBubbling
)
Boolean

Defined in parsley.js:670

Validate a field & display errors

Parameters:

  • errorBubbling Boolean

    set to false if you just want valid boolean without error bubbling next to fields

Returns:

Boolean:

Is field valid or not