防止回车键意外提交,用户必须用鼠标点击提交按钮才能提交表单。此代码在IE中测试通过。
第一步:
在<head>区添加以下代码
<SCRIPT LANGUAGE="JavaScript">
/*****************************************************
* Share JavaScript (http://www.ShareJS.com)
* 使用此脚本程序,请保留此声明
* 获取此脚本以及更多的JavaScript程序,请访问 http://www.ShareJS.com
******************************************************/
function onKeyPress () {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13) {
alert("Please Click on the Submit button to send this");
return false
}
return true
}
document.onkeypress = onKeyPress;
</script>
第二步:
在<body>区添加以下代码
<input type="text"> <input type=submit>




