0
我需要當用戶按ENTER鍵時表單不提交。我已經做到了,但是當警報到來並且用戶接受時,表單會提交。它只發生在Safari用戶身上。提醒後刷新頁面確定
我的代碼!並感謝...
<script>
function alerta(e)
{
var unicode
if (e.charCode)
{unicode=e.charCode;}
else
{unicode=e.keyCode;}
if (unicode == 13){
alert("message alert");
window.location.reload();
}
}
</script>
<form method="post" action="verifi.php" onkeypress="alerta(event)">
...
</form>
調用'e.preventDefault()'以防止表單提交。 – Barmar
但我需要表單提交,但不是在Safari中的用戶接受提醒時。 PS:我從JavaScript開始,沒有太多的經驗。 –
在「if」塊中執行該操作。 – Barmar