Fork me on GitHub

Events

After the plugin has been fired, a series of custom events are available for the form and fields.
Use these custom events to manually controll the validations.


Custom events for the form.

Event / parameters Description
addField Add a field to be validated to the form.
(
field The field to be added.
Possible values: String, HTML element or jQuery object.
)
destroy Completely removes all validation behavior from the form and fields.
validate Validate all fields within the given scope.
(
scope The scope wherein the fields should be validated.
Possible values: String, HTML element or jQuery object.
Default value: The HTML element the plugin was fired on.
callCallback Whether to call the form.onValid or form.onInvalid callback function after the fields have been validated.
Possible values: true or false.
Default value: false if scope is defined, true otherwise.
)
submitForm Triggers the validate custom event and removes all placeholder values so the form can be submitted.
resetForm Resets all fields to the original value.
options Get or set the options after firing the plugin.
Return value: an object of the options.
(
options An object of the options to merge into the already existing options.
If omiited, the event will only function as a getter.
)


Custom events for the fields.

Event / parameters Description
validate Validates the field.
(
callCallbacks Whether to call the fields.onValid or fields.onInvalid callback function after the field has been validated.
Possible values: "valid", "invalid" or true.
Default value: true.
)
validations Get or set the validations for the field.
(
validations The validations to set.
Possible values: String, Array, if omitted the event works as a getter.
)
addValidation Add a validation to the field.
(
validation The validation to add.
Possible values: String.
)
removeValidation Remove a validation from the field.
(
validation The validation to remove.
Possible values: String.
)
isValid Get or set the field "valid".
(
isValid SET the field to valid/invalid (true/false).
Possible values: Boolean, if omitted the event works as a getter.
callCallbacks Whether to call the fields.onValid or fields.onInvalid callback function.
)
destroy Completely removes all validation behavior from the field.


Using namespaces.
All custom events are bound to the .vv namespace. Trigger them using the namespace:

$( "#myButton" ).click({
	$( "#myForm" ).trigger( "validate.vv" );
});

Share to FacebookShare to TwitterStumble itMore...