[英]Form submit Alert OK
Hi I want the form I'm making to submit but not before the users press ENTER key without accepting terms and conditions. 嗨,我想要我要提交的表单,但不要在用户按ENTER键而不接受条款和条件之前提交。
I already made that but in Safari when the user press ENTER, the alert appears, you press OK and the form submits. 我已经做到了,但是在Safari中,当用户按ENTER键时,出现警报,然后按OK并提交表单。 That's what I want to fix. 这就是我要解决的问题。 Thanks 谢谢
<script>
function alerta(e)
{
var unicode
if (e.charCode)
{unicode=e.charCode;}
else
{unicode=e.keyCode;}
if (unicode == 13){
alert("alert message");
}
}
</script>
<form method="post" action="..php" onkeypress="alerta(event)">
...
</form>
Use onsubmit attribute on form, and return false, if checkbox not checked. 在表单上使用onsubmit属性,如果未选中此复选框,则返回false。
Or, if you have popup dialog - onsubmit should return false, and pressing "accept" button in dialog trigger form.submit() 或者,如果您有弹出对话框-onsubmit应该返回false,然后在对话框触发器form.submit()中按“接受”按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.