当单击 WordPress 重力表单的提交按钮时,我使用以下代码输出确认框:
$(".gform_wrapper.form-01 form").submit(function(event) {
confirm('Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse.');
});
弹出窗口工作正常,但如果用户单击“取消”按钮,我需要它来阻止表单提交。但无论在确认中单击哪个按钮,表单都会提交。
最佳答案
设法自己修复它(一次!)
$('.gform_wrapper.form-01 form input[type="submit"]').click(function(event) {
event.preventDefault();
var c = confirm('Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse.');
if (c == true) {
$(this).closest('form').submit();
} else {
alert('no');
}
});
关于jquery - 使用确认框防止重力形式提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26346055/