我正在尝试强制提交表单,问题是我使用bootboxjs (使用异步代码)在提交之前进行确认对话,这正是我想要的,也是以这种方式验证所需的输入。
这是我的JS代码的结构:
$("#myForm").submit(function(e){
bootbox.confirm({
message: "Are you sure?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-danger'
},
cancel: {
label: 'NO, STOP!',
className: 'btn-primary'
}
},
callback: function (result){
if (result)
{
// Some code to set values to hidden inputs and another irrelevant stuff...
// The right command (that I didn't know) to force the form
}
}
});
return false;
});
如何避免此问题并保留所需输入的验证?
答案 0 :(得分:1)
您可以阻止jquery事件并使用本机事件在您准备好时强制执行浏览器默认提交
#[Minutes, Seconds, Distance in miles]
[17, 37, 3.1]
#17 * 60 = 1020; 1020 + 37 = 1057; 1057/3.1 = 340.96