Closed lynzz closed 11 years ago
如我定义个规则如下: Validator.addRule('checkEmail', function(options, commit) { $.ajax({ url:'<%=basePath%>member/member_check?mode=checkEmailAvailable', data:{checkStr: options.element.val()}, complete: function(data) { data = eval('(' + data.responseText + ')'); commit(data.state == 'ok' ? null : data.state, data.msg); } }) }); var myEmail = Validator.getRule('email').and('checkEmail'); 此时如在input框输入错误的email,确是提示“请输入邮箱”,即提示的内容是data-explain里的值,按理要提示“邮箱的格式不正确”
找到了,直接这样用就行了 validator.addItem({ element: '#email', required: true, display:'邮箱', rule: 'email checkEmail' })
如我定义个规则如下: Validator.addRule('checkEmail', function(options, commit) { $.ajax({ url:'<%=basePath%>member/member_check?mode=checkEmailAvailable', data:{checkStr: options.element.val()}, complete: function(data) { data = eval('(' + data.responseText + ')'); commit(data.state == 'ok' ? null : data.state, data.msg); } }) }); var myEmail = Validator.getRule('email').and('checkEmail'); 此时如在input框输入错误的email,确是提示“请输入邮箱”,即提示的内容是data-explain里的值,按理要提示“邮箱的格式不正确”