HTML / JS登录表单问题

时间:2017-05-24 22:07:35

标签: javascript html login

我的登录表单功能有问题。我想让任何用户按回车键检查表格,这是行不通的。它只是将表单提交到url(url.com/?pswrd=password)而不是使用checkForm()函数。它完成的是HTML和javascript,并且没有任何东西在服务器端完成。

    <form onsubmit="checkForm(this)">
        <input id="password"
         type="password"
         name="pswrd"/>
        <input id="btn" type="button" onclick="checkForm(this.form)" value="Login" class="hvr-float-shadow"/>
    </form>
    </font>
    <script>
        function checkForm(form) {
             if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
             else if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
             else if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
             else if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
             else if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
             else if(form.pswrd.value == "[censored]") {
                window.location.replace('/indexproxy.php')
            }
            else {
                alert("Incorrect access code, please try again.");
            }
};
    </script>
<font face=arial color=white size=2>
<p>All access codes are CaSe SeNsiTIVE</p>
</body>
</center>
</html>

1 个答案:

答案 0 :(得分:0)

您可以在下面的链接中找到代码示例;

http://www.javascript-coder.com/html-form/html-form-action.phtml