JavaScript Enter键按下

时间:2018-11-25 03:10:00

标签: javascript html enter

因此,我为密码页面提供了一些简单的代码,我试图获取要使用的回车键,而不必总是单击提交按钮。我需要帮助!!!

  <div class="pas">    
        <input id="pswd" type="password" id="pswd" placeholder="Password" required="password" > <br>

  </div>

  <div class="submit">

  <input id="subm"  type="button" value="Submit" onclick="checkPswd();" />
  </div>  





 <script type="text/javascript">

                    function checkPswd() {
                    var confirmPassword = "admin";
                    var password = document.getElementById("pswd").value;
                    if (password == confirmPassword) {
                        window.location="main.html";
                    }
                    else{
                        alert("Password is incorrect.");
                    }
                }   




            </script>

0 个答案:

没有答案