我的目标是仅在用户单击 SweetAlert 框上的“确定”后才允许提交表单。
所以,他点击一张图片(表格),出现带有一些说明的框,他阅读并点击“确定”,然后提交表格。
这是表单代码:
<form id="formpag" action="https://example.com/request.html" method="post">
<input type="hidden" name="code" value="7055C88A445678A00461CFA120F4A2E7" />
<input type="image" src="https://example.com/buttons/subscriptions/120x53-subscribe.gif" name="submit" alt="Pay with Example.com - it is fast and reliable!" />
</form>
现在是 jQuery/Sweet Alert 部分:
jQuery( document ).ready(function( $ ) {
$(function() {
$('#formpag').submit(function() {
swal({ title: "Be Advised",
text: "You need to check your email account after payment.",
imageUrl: "images/thumbs-up.jpg" });
});
});
});
问题:就像现在一样,框正在向用户显示,但几秒钟后,表单正在提交,即使他没有点击 SweetAlert 框上的 OK 按钮。
只有当他单击“确定”时才必须提交表格。
任何帮助将非常感激。(对不起,我知道这是一个愚蠢的问题,但 SweetAlert 文档并没有帮助我)。