我在我的表单上使用了以下验证,因为我有email address
字段和confirm email address
字段我需要进行一些验证以确保这两个字段匹配,我目前有以下内容给出我发现它不匹配的错误信息即使有,也不知道为什么会这样?
rules: {
'entry[email]': {
required: true,
email: true
},
'entry[confirm_email]': {
// required: true,
equalTo: "entry[email]"
},
},
messages: {
'entry[email]': {
required: ' Please enter a valid email address',
minlength: 'Not a valid email address'
},
'entry[confirm_email]': {
required: ' Please make sure email matches above',
minlength: 'Does not match above email address'
},
}
答案 0 :(得分:2)
试试这种方式
rules:{
pwd:{
required:true //First email section
},
pwd1:{
required:true,//Second email section
equalTo: "#same" //Use id of the first email text box here
}
},
messages:{
pwd1:{
equalTo: "Must be same as above email"
}
}
答案 1 :(得分:0)
$('#email).validate({
...
rules: {
...
'entry[confirm_email]': {
equalTo: "entry[email]"
}
}
});
此处"条目[email]"应该是输入元素的id !!