日期:2014-05-16  浏览次数:20322 次

onkeypress与submit问题
<input   name= "aa "   type= "text "   style= "width:30px "   onKeyPress= "return   event.keyCode> =48&&event.keyCode <=57 "   value= "0 "/>
<input   type= "submit "   name= "Submit "   value= "提交登记信息 "   onkeypress= "form_in.submit "   />


现在问题是这样的

在input   aa中我加了onkeypress来验证输入数字,可为什么我在input   aa中输入完毕后直接敲回车不能自动提交,而是要手动呢

------解决方案--------------------
<input name= "aa " type= "text " style= "width:30px " onKeyPress= "return event.keyCode> =48&&event.keyCode <=57||event.keyCode=13 " value= "0 "/>
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>

<BODY>
<FORM METHOD=POST ACTION= " ">
<INPUT TYPE= "text " id= "aa ">
<INPUT TYPE= "text " id= "bb ">
<INPUT TYPE= "text " id= "cc ">
<INPUT type= "button " id= "Submit " onclick= "alert( 'ddd '); " value = "click ">
</FORM>
</BODY>
<script language= "JavaScript1.2 ">
<!--
var objinput = document.all.tags( "input ")
for (i=0;i <objinput.length;i++)
{
objinput[i].onkeypress=
function EnterEvent()
{
if(event.keyCode==13)
{
document.all.Submit.click();
return false;
}
}
}
//-->
</script>

</HTML>