这个表单验证支持空值,长度,范围,群组,ajax
示例效果
验证模式1 验证模式2
类别 | 类别1 类别2 类别3 类别4 |
项目 | 项目1 项目2 项目3 项目4 |
示例代码
Validator.add({ id: 'Name', name: '用户名', type: 'require length ajax', min: 5, max: 200, ajax: { value: function() { if (document.getElementById('Name').value == 'known') return true; else return false; }, message: '用户名已经存在!' } }); Validator.add({ id: 'Password', name: '密码', type: 'require' }); Validator.add({ id: 'Type', name: '类别', type: 'group' }); Validator.add({ id: 'Item', name: '项目', type: 'group' }); if (Validator.validate(document.forms[0].m[0].checked ? 1 : 2)) { Pop.confirm({ info: '确认送出?', ok: function() { Pop.wait(); document.forms[0].submit(); }, cancel: function() { return false; } }); } return false;