jquery等于函数表单验证
我一直在用 jQuery 进行一些表单验证。一切都很顺利,然后我意识到我需要做一个密码并确认密码验证方法。到目前为止,我已经:
'dotwPassword': function () {
var info = $('.dotwPassword');
var ele = $('#dotwPassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
'dotwConpassword': function () {
var info = $('.dotwConpassword');
var ele = $('#dotwConpassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
任何人都可以告诉我如何在密码上添加密码匹配项,以便这两个字段必须相同才能继续并发送表单?
预先感谢
理查德
I have been working on some form validation in jQuery. Everything was going nicely and then I realised I need to do a password and confirm password validation method. I have so far:
'dotwPassword': function () {
var info = $('.dotwPassword');
var ele = $('#dotwPassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
'dotwConpassword': function () {
var info = $('.dotwConpassword');
var ele = $('#dotwConpassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
Can anyone show me how to add in a match for password on conpassword so these 2 fields have to be the same in order to proceed and send the form?
Thanks in advance
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否只需要向两个函数添加以下测试:
您可以将其添加到您已有的相同 if 测试中:
或者单独处理它。
Don't you just need to add the following test to both functions:
You could add that to the same if test you already have:
Or handle it separately.