码迷,mamicode.com
首页 > 其他好文 > 详细

validator

时间:2016-04-21 01:29:14      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

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.‘);

validator

标签:

原文地址:http://www.cnblogs.com/jayruan/p/5415159.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!