【发布时间】:2018-06-07 06:35:14
【问题描述】:
我正在提交表单,我正在显示一个确认框,询问用户他们是否真的想继续。但即使用户点击取消,表单仍然会被提交。
<form onsubmit="return confirm('If you enter the incorrect number, the search will still be conducted and charge you for the cost of the search. do you want to continue?.')" action="http:example.com/" id="customersearch" name="customersearch" role="form" method="post" accept-charset="utf-8" novalidate="novalidate">
我怎样才能避免这种情况?谁能告诉我当用户点击取消时如何阻止表单提交?
【问题讨论】:
-
使用您的代码的 codepen/jsfiddle/plunker 等发布工作代码 sn-p。那将很容易调试。以上信息不充分
-
将您的确认放入条件语句中,根据用户选择相应返回或阻止
-
你是如何提交的?
标签: javascript html forms form-submit confirm