validator

时间:2024-07-13 22:37:08

http://rickharrison.github.io/validate.js/validate.js

rules: 'required|callback_check_password'

validator.registerCallback('check_password', function(value) {
if (passwordIsStrong(value)) {
return true;
}

return false;
})
.setMessage('check_password', 'Please choose a stronger password using at least 1 number.');

validator.setMessage('required', 'You must fill out the %s field.');

var validator = new FormValidator('example_form', [{
name: 'req',
display: 'required',
rules: 'required'
}, {
name: 'alphanumeric',
rules: 'alpha_numeric'
}, {
name: 'password',
rules: 'required'
}, {
name: 'password_confirm',
display: 'password confirmation',
rules: 'required|matches[password]'
}, {
name: 'email',
rules: 'valid_email',
depends: function() {
return Math.random() > .5;
}
}, {
name: 'minlength',
display: 'min length',
rules: 'min_length[8]'
}], function(errors, event) {
if (errors.length > 0) {
// Show the errors
}
});
1,rules: 'required'
2,rules: 'required|matches[password]'
3,rules: 'min_length[8]'
4,rules: 'valid_email',

validator.registerCallback('check_password', function(value) {
if (passwordIsStrong(value)) {
return true;
}

return false;
})
.setMessage('check_password', 'Please choose a stronger password using at least 1 number.');