Support development of this plugin by donation
jQuery Validator Plugin provides validation for user input in many different formats. This is a first public release of this plugin, so there are more features (such as additional and improved validation formats) coming in future versions.
Most of the validation formats are shown in demos above with the source code.
Supported Formats
- IP Address
- Date
- Date and Time
- Phone
- US Zip Code
- Canada Zip Code
- Credit Card
- Numeric
- Decimal
- Alphanumeric
Usage
Validator PlugIn needs jQuery any 1.3.x version to operate correctly.
In addition, validator.js and validator.css files should be loaded in the header.
For validation to work, validator should be attached to each field that needs to be validated prior to that.
Below is the basic code to attach validator:
jQuery(function($){
$('#field').validator();
});
After validator is attached, it will validate field on specific event (change and blur by default) or by calling validate method:
jQuery(function($){
$('#field').validator('validate');
});
- Type:
- string
- Default:
- validator_error
- Type:
- string
- Default:
- change blur
- Type:
- string
- Default:
- null
Supported formats:
- Key:
- Example:
- email@domain.com
- Key:
- ip
- Example:
- 111.111.111.111
- Key:
- date
- Example:
- mm/dd/yyyy
mm-dd-yyyy
mm.dd.yyyy
mm dd yyyy
- Key:
- datetime
- Example:
- hh:mm
hh.mm
hh-mm
hh mm
- Key:
- phone
- Example:
- 10-15 digits
0123456789
- Key:
- zipUS
- Example:
- 5 or 9 number formats
12345-0000
- Key:
- zipCanada
- Example:
- A6A 6A6
- Key:
- creditCard
- Example:
- Key:
- numeric
- Example:
- digits only
- Key:
- decimal
- Example:
- 1,000.04
- Key:
- alphanumeric
- Example:
- Type:
- boolean
- Default:
- false
- Type:
- integer
- Default:
- null
- Type:
- integer
- Default:
- null
- Type:
- number
- Default:
- null
- Type:
- number
- Default:
- null
- Type:
- string, regexp
- Default:
- null
- Type:
- string, regexp
- Default:
- null
- Type:
- string
- Default:
- null
- Type:
- string
- Default:
- null
- Type:
- boolean
- Default:
- null
- Arguments:
- field, value
- Return:
- string
this equals to field element that is used in validation.
Arguments:
- field: field element that is used in validation
- value: value of the field
- Arguments:
- field, value, error
- Return:
- string
Any changes to error object will affect error notification that follows this function call.
this equals to field element that is used in validation.
Arguments:
- field: field element that is used in validation
- value: value of the field
- error: object with 3 parameters: boolean status, string type, string message
- Arguments:
- field, value, error
- Return:
- boolean
this equals to field element that is used in validation.
Arguments:
- field: field element that is used in validation
- value: value of the field
- error: object with 3 parameters: boolean status, string type, string message
- Arguments:
- field, value
- Return:
- boolean
this equals to field element that is used in validation.
Arguments:
- field: field element that is used in validation
- value: value of the field
Version 0.1.3
- Added support for international characters in alphanumeric validation format
- Following characters added into alphanumeric validation format: space, hyphen (-), underscore (_), and dot (.).
Version 0.1
- The first public release.
igor [DOT] gladkov [AT] gmail [DOT] com
or
just go to the project page.
Support forum will be installed in near future.