我有以下jquery验证表单,我想在验证中传递额外的参数,所以在提交表单时,该值也传递表单数据并发送到我的php服务器进行处理,
var handleAddNewTest = function (filenames) {
var form1 = $('#test_fm');
console.log(filenames); //I can see filenames in console output...
form1.validate({
rules: {
test_date: {
required: true,
},
.....
.....
submitHandler: function(form) {
console.log(filenames); //I cant see in console output, it shows undefined.
some ajax....
});
}
如何将文件名值带到jquery验证插件的submitHandler?
答案 0 :(得分:0)
您应该将它作为参数传递给submitHandler函数:
submitHandler: function(form, filenames) {
console.log(filenames);
}