在 pdf 下载链接上需要打开一个 jQuery 对话框,并有一个带有姓名、电子邮件和确认复选框的表单。
将在字段上进行一些验证,例如。所需的最小和最大尺寸等...
已在页面加载时初始化对话框,并在 pdf 下载链接上打开对话框。
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
modal: true,
buttons: {
'Continue': function(){
var valid = true;
valid = valid && checkExists(name, 2, 50);
//valid = valid && checkEmail(email);
valid = valid && checkTrue(agree);
if(valid) {
//ajax call to controller
return true;
}
},
'Cancel': function(){
$(this).dialog('close');
}
}
});
$("a.download-document").click(function(){
$("#dialog").dialog('open');
});
我遇到的问题是,因为我在 click 事件上没有 return false ,所以它会打开对话框,然后继续 click 事件。
如何让单击事件仅在提交表单并且验证正常时才继续?