https://github.com/duzun/jquery.validate
Form validation plugin
https://github.com/duzun/jquery.validate
async asynchronous form html jquery jquery-plugin remote validation
Last synced: 6 months ago
JSON representation
Form validation plugin
- Host: GitHub
- URL: https://github.com/duzun/jquery.validate
- Owner: duzun
- License: mit
- Created: 2021-02-20T11:23:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-20T11:35:44.000Z (over 4 years ago)
- Last Synced: 2025-03-30T11:34:29.980Z (6 months ago)
- Topics: async, asynchronous, form, html, jquery, jquery-plugin, remote, validation
- Homepage:
- Size: 122 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Form validation plugin
## Description
This plugin contains a set of validation rules, assigned to each field by
special attributes and classes (eg ``).Custom rules can be defined per instance. Each custom rule is a `function (value, $element, data)`.
If rule returns `false`, `Error` or a rejected (later) `Promise`, field is invalid,
otherwise the rule is considered passed.Error message is user as invalid hint.
Promise error should be a string or an object with either .message or .msg field.
## Usage
### Example
```js
$('#myForm')
.validator({
fieldGroup: '.form-group',
hintElement: '.invalid-hint',rules: {
my_field: {
required: function (value, $elem, data) {
if ( !value ) {
return new Error('Field is required');
}
},
unique: function(value, $elem, data) {
return $.when($.ajax({ url:'/my/validation', data:{ value: value, rule: data.rule } }));
},number: function(value) { return !isNaN(value) },
not_number: isNaN
}
}
});
```