如何将重定向添加到HTML5表单?

时间:2013-10-26 16:10:44

标签: html5 forms

我的网站上有2个表单,而不是提交这些表单,我希望用户只需在尝试提交表单时重定向到新的注册页面(让我们称之为http://signup.com)。

代码如下 - 我将如何实现这一目标?

由于

FK


表格1

            <form action="" class="header-signup">
                <input name="email" class="input-side" type="email" placeholder="Sign up now">
                <input type="submit" value="Go" class="btn-side">
            </form>

表格2

            <form action="" class="signup-form">
                <input name="email" class="input-side animate-on-scroll" data-scrollanimation="fadeInLeft" type="email" placeholder="Your email address">
                <input type="submit" value="Sign Up Now" class="btn-side animate-on-scroll" data-scrollanimation="fadeInRight">
            </form> 

1 个答案:

答案 0 :(得分:1)

尝试:

        <form action="" class="header-signup">
            <input name="email" id="txt-email" class="input-side" type="email" placeholder="Sign up now">
            <input type="button" value="Go" id="btn-go" class="btn-side">
        </form>
        <script>
            function moveToSignUpLocation() {
                    window.location = "[location to sign up]";
            }
            document.getElementById('txt-email').onkeydown = function(e) {
                 e = e || window.event;
                 if (e.keyCode === 13) {
                    moveToSignUpLocation();
                 }
            }
            document.getElementById('btn-go').onclick = function() {
                           moveToSignUpLocation();
            };
        </script>