onkeypress=if(window.event.keyCode==13)...

解决方案 »

  1.   

    <!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="Seagle.K">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="JavaScript">
    function submitaction(thisform, force)
    {
    if (event.keyCode == 13 || force == 1)
    {
    alert('帐号:' + thisform.txt.value + '\n' + '密码:' + thisform.pwd.value);
    if (confirm('I\'m a common button,would u submit for sure?'))
    {
    thisform.submit();
    }
    }
    }
    </script>
    <style type="text/css"></style>
    </head>
    <body>
    <form method="POST" action="" target="_blank" onkeydown="submitaction(this, 0)">
    帐号:<input type="text" name="txt" value=""><br>
    密码:<input type="password" name="pwd" value=""><br>
    <input type="button" value="submit" name="btn" onclick="submitaction(this.form, 1)">
    </form>
    </body>
    </html>