window.console
property exists). Try to enable when a form is just submitted instead of validation stopping the submit.
Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages.
1
2
3
|
|
native form submit
)
Example: Submits the form via Ajax when valid.
1
2
3
4
5
|
|
Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again.
1
2
3
4
5
6
|
|
The callback gets passed one argument:
Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
|
The callback gets passed two arguments:
":hidden"
)
Example: Ignores all elements with the class "ignore" when validating.
1
2
3
|
|
rules are read from markup (classes, attributes, data)
)
Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal).
1
2
3
4
5
6
7
8
9
10
11
|
|
Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email.
1
2
3
4
5
6
7
8
9
10
11
12
|
|
Example: Configure a rule that requires a parameter, along with a depends
callback.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
|
the default message for the method used
)
Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
|
Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
|
Example: Use a table layout for the form, placing error messags in the next cell after the input.
1
2
3
4
5
6
7
8
9
10
11
12
|
|
true
)
Set to a Function to decide for yourself when to run validation.
A boolean true is not a valid value.
Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise).
1
2
3
|
|
Set to a Function to decide for yourself when to run validation.
A boolean true is not a valid value.
Example: Disables onblur validation.
1
2
3
|
|
The callback gets passed two arguments:
Set to a Function to decide for yourself when to run validation.
A boolean true is not a valid value.
Example: Disables onkeyup validation.
1
2
3
|
|
The callback gets passed two arguments:
Set to a Function to decide for yourself when to run validation.
A boolean true is not a valid value.
Example: Disables onclick validation of checkboxes and radio buttons.
1
2
3
|
|
The callback gets passed two arguments:
true
)
Example: Disables focusing of invalid elements.
1
2
3
|
|
false
)
Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused.
1
2
3
|
|
"error"
)
Example: Sets the error class to "invalid".
1
2
3
|
|
"valid"
)
Example: Sets the valid class to "success".
1
2
3
|
|
"label"
)
Example: Sets the error element to "em".
1
2
3
|
|
window
)
Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container.
1
2
3
|
|
Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages.
1
2
3
4
5
|
|
Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option).
1
2
3
4
5
6
|
|
Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display.
1
2
3
4
5
6
7
8
|
|
The callback gets passed two arguments:
Places the error label after the invalid element
)
Example: Use a table layout for the form, placing error messages in the next cell after the input.
1
2
3
4
5
|
|
The callback gets passed two arguments:
Example: Add a class "valid" to valid elements, styled via CSS.
1
2
3
4
|
|
Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!".
1
2
3
4
5
6
|
|
The callback gets passed two arguments:
Adds errorClass (see the option) to the element
)
Example: Highlights an invalid element by fading it out and in again.
1
2
3
4
5
6
7
|
|
Example: Adds the error class to both the invalid element and its label
1
2
3
4
5
6
7
8
9
10
11
12
|
|
The callback gets passed three arguments:
input
.
errorClass
option.
validClass
option.
Removes the errorClass
)
false
)
Example: Configure the plugin to ignore title attributes on validated elements when looking for messages.
1
2
3
|
|
Use the debug option to ease setting up validation rules, it always prevents the default submit, even when script errors occur.
Use submitHandler to implement your own form submit, eg. via Ajax. Use invalidHandler to react when an invalid form is submitted.
Use rules and messages to specify which elements to validate, and how. See rules() for more details about specifying validation rules.
Use errorClass, errorElement, wrapper, errorLabelContainer, errorContainer, showErrors, success, errorPlacement, highlight, unhighlight, and ignoreTitle to control how invalid elements and error messages are displayed.