seelang2 / formvalidator

jQuery form validation plugin that filters a collection of data fields and returns the invalid fields.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

formvalidator

Formvalidator is a jQuery plugin that performs basic field validation based on html attributes. When called on an element containing data fields (such as a form element) the plugin traverses to the data fields and returns a collection of invalid fields.

The plugin uses several html data attributes to perform its validation: 'data-vrule', 'data-vminval', 'data-vmaxval', 'data-vregex', and 'data-verror'. The first attribute, 'data-vrule', sets the validation rule to be applied to the element. If 'data-vrule' is not present the field is ignored and assumed valid. The next three attributes are optional parameters used in various validation rules as described below.

The last attribute, 'data-verror', is set by the plugin on each element that is returned by the plugin and contains a message describing the validation error.

The validation rule for the field is set using the 'data-vrule' attribute. The following rules are supported:

notemptyThe field cannot be empty
minlengthfield has a minimum length specified in 'data-vminval'
maxlengthfield has a maximum length specified in 'data-vmaxval'
lenbetweenfield must have a length between the values in 'data-vminval' and 'data-vmaxval' inclusive
valbetweenfield must have a value between the values in 'data-vminval' and 'data-vmaxval' inclusive
isnumericfield must be a valid number (float or integer)
isalphafield only contains the letters a-z
isalphanumericfield only contains the letters a-z and numbers 0-9
isemailfield appears to be a valid email address
matchregexfield matches the regular expression given in 'data-vregex'

About

jQuery form validation plugin that filters a collection of data fields and returns the invalid fields.

License:MIT License


Languages

Language:JavaScript 100.0%