因为你"ctrl+回车"触发了ctlent(),并且回车也触发了submit按钮,又执行一次checkform()
解决方案 »
- 字符串反转为什么提示我undefined 求高手解答 谢谢
- 楼层内各个单元状态图
- 不同js页面动态加载 方法
- jquery实现的经典模式幻灯片效果
- document.all.myid 跟document.forms[0].myid有什么区别
- js读取textarea的问题 如何读取某一起始位置的内容
- 请问 用 toFixed(4) 后 ,如何 去除 多余的 0 ?
- 编好了web自由查询界面,纯javascript,共享之
- 在框架中调入别的HTML文件,如何使用框架中的文件不能改变顶框架的路径。
- 那位高手帮我看看,当form1中的文本框输入回车时出错!(马上结!!)
- js读网页内容
- js给embed的src赋值问题
去掉试试
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script>
//表单验证
function checkform(){
with(form1){
if(name.value==''){
alert('Please input your username.');
name.focus();
return false;
}if(password.value=='' || password.value.length<6){
alert('It needs 6 charectors at least your password.');
password.focus();
return false;
}
return true;
}
}//快捷键提交表单
ie=(document.all)?true:false;
if(ie){
function ctlent(eventobject){
if(event.ctrlKey && window.event.keyCode==13){//ctrl+回车
if(checkform()) this.document.form1.submit();
}
}
//document.body.onkeydown=ctlent;//相当于在<body>标签内加onkeydown="ctlent();",但此处不能加括号()
}
function submit_onclick(){
if(checkform()){
document.form1.submit();
}
}
</script></head><body onkeydown="ctlent();">
<form action="login.asp" method=POST name=form1 onsubmit="return checkform();">
username: <input type="text" name="name" size="20" value=""><br/>
password: <input type="password" name="password" size="20" value=""><br/>
<input type="button" value="submit" onclick="submit_onclick()"><span style="font-size:12px">(也可用Ctrl+enter提交表单)</span>
</form>
</body>
</html>
改写submit部分