目前我尝试解析两个值虽然jQuerys验证插件以检查SQL数据库。我可以看到DateReceived正在被正确解析,但是CentreID总是出现为null。
这是我目前的代码:
var centreID = $( '#CentreSelect' ).val();
$("#submit-form").validate({
rules: {
DateReceived:{
required: true,
remote:{
url: "url.php?CentreID=" + centreID,
type: "GET"
}
},
},
messages: {
DateReceived: {
remote: "Error - Centre already entered on that date"
}
}
});
});
我们非常感谢您的建议。
答案 0 :(得分:2)
你需要
$("#submit-form").validate({
rules: {
DateReceived: {
required: true,
remote: {
url: "url.php?CentreID=" + centreID,
data: {
CentreID: function () {
//you need to read this value when the validation is executed, so pass the value as a function which will be called
return $('#CentreSelect').val()
}
}
type: "GET"
}
},
},
messages: {
DateReceived: {
remote: "Error - Centre already entered on that date"
}
}
});
答案 1 :(得分:0)
嘿,男人在调用验证函数后尝试读取centreID。