如何使用具有名称模式的 ids 的 jQuery 插件验证表单,例如#formNewHouse1、#formNewHouse2、..?
此代码使用单一类型(正常)形式:
$("#formNewHouse").validate({
rules: {
formNewHouseName: {
required: true
},
formNewHouseAddress: {
required: true
}
},
messages: {
formNewHouseName: {
required: "Please type a name"
},
formNewHouseAddress: {
required: "Please type an address"
}
}
});
我需要这样的东西,其中 X = 2,3,6,18,19,...(来自 DB 的 ID)我该如何实现?
$("#formNewHouseX").validate({
rules: {
formNewHouseNameX: {
required: true
},
formNewHouseAddressX: {
required: true
}
},
messages: {
formNewHouseNameX: {
required: "Please type a name"
},
formNewHouseAddressX: {
required: "Please type an address"
}
}
});
提前致谢。