If the form includes only one text box and the user presses ENTER, the onsubmit event fires. If the form has an INPUT type=submit element, it will appear as a button with a dark border, which indicates the user can press ENTER to submit the form. 如果表单仅包含一个文本框时用户按下回车键,onsubmit 事件将触发。如果表单有 INPUT type=submit 元素,该元素将会变为带有黑色边框,这意味着用户按下回车键即可提交表单。
<script>
function document.onkeypress()
{
if(event.keyCode==13)
{
return false;
}
}
</script>
function document.onkeypress()
{
if(event.keyCode==13)
{
return false;
}
}
</script>
If the form includes only one text box and the user presses ENTER, the onsubmit event fires. If the form has an INPUT type=submit element, it will appear as a button with a dark border, which indicates the user can press ENTER to submit the form.
如果表单仅包含一个文本框时用户按下回车键,onsubmit 事件将触发。如果表单有 INPUT type=submit 元素,该元素将会变为带有黑色边框,这意味着用户按下回车键即可提交表单。
也就是说,如果form中只有一个文本框,会直接触发onsubmit 事件,而不去执行INPUT type=submit 元素的onclick事件。