回车键提交表单

<HTML>
<HEAD>
<TITLE> Enter Event </TITLE>

<script language="javascript">
function enterkey()
{
    try
    {
        var el_keydown=window.event.srcElement;
        if(event.keyCode==13 && el_keydown.id=="txt1")     {                      
           alert(1111);
            txt2.focus();
        }
        else if(event.keyCode==13 && el_keydown.id=="txt2") {
            alert(222);
            btn.focus();
        }
    }
    catch(e)
    {
        return;
    }
}

</script>

</HEAD>

<BODY>
<input type="text" id="txt1" onkeyDown="enterkey();" ><br>
<input type="text" id="txt2" onkeyDown="enterkey();" ><br>
<input type="button" id="btn" value="button" onClick="alert(txt2.value)" >
</BODY>
</HTML>

    A+
发布日期:2009年08月12日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: