我有一个地址字段街道,城市,州,邮政编码的表格,我有另一个组与确认地址相同的字段。我想在jQuery validation plugin中的地址和确认地址之间应用 equalTo 插件选项。还要查找此确认案例的组错误消息,如下所示。
表格模式
Address
street
city
state
zipcode
Confirm Address
street > error : Your address is not matching
city
state
zipcode
答案 0 :(得分:2)
$(function () {
$("#addressForm").validate({
group:{
address : "street city state zipcode",
confirm_address : "street1 city1 state1 zipcode1",
},
rules: {
street: {
required: true
},
city: {
required: true
},
state: {
required: true
},
zipcode: {
required: true
},
street1: {
required: true,
equalTo : "#street"
},
city1: {
required: true,
equalTo : "#city"
},
state1: {
required: true,
equalTo : "#state"
},
zipcode1: {
required: true,
equalTo : "#zipcode"
}
}
});
});