点击按钮才能提交

2008-10-01 08:57:00 | 【
在输入框里回车,会弹出警告框,点击Submit按钮无反应

防止回车键意外提交,用户必须用鼠标点击提交按钮才能提交表单。此代码在IE中测试通过。

查看全部代码 View Code

第一步:
在<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>

下载"点击按钮才能提交"

  • 本地下载
  • 本地下载2

相关资源