输入按钮不在Fancybox中工作

时间:2013-12-22 23:52:55

标签: php jquery html forms fancybox

我在fancybox弹出窗口中有一个登录表单,由于某种原因,提交按钮不起作用。

我尝试使用不同的html输入类型,如下所示。

使用type="button"表格有效但当我点击输入时不提交表单

使用type="submit",当我点击提交或按回车键时,表单根本无效,只需将我重定向到mysite.com/?login=&pass=&submit=SIGN+IN+TO+YOUR+ACCOUNT关闭精美的方框

以下是表单代码

<div style="display:none">
    <div id="sign_in" class="fancybox_message sign_in_popup">
        <div class="login_form_container">
            <h1 class="semibold">SIGN IN TO YOUR ACCOUNT</h1>
            <form>
                <input type="text" name="login" id="login" class="regular" autocomplete="off" placeholder="Username or Email" />
                <input type="password" name="pass" id="pass" class="regular" autocomplete="off" placeholder="Password" />
                <div class="clear"></div>
                <div class="squaredFour">
                    <input style="display: none;" type="checkbox" value="None" id="squaredFour" name="check" />
                    <label for="squaredFour"></label>
                </div>
                <span class="regular remember">Remember me</span>
                <a href="#" class="regular forgot">Forgot your username/password?</a>
                <div class="errorHolder" style="float: left;margin-top:5px;color:red"></div>
                <input type="button" name="submit" id="ajaxLogin" class="semibold submit" value="SIGN IN TO YOUR ACCOUNT" />
            </form>
        </div>
        <div class="login_social_container">
            <!--<a href="<?php echo $website_domain.'/account/auth.php?pl=facebook'; ?>"><img src="<?php echo $website_domain; ?>/assets/images/login_facebook.png" alt="Login from facebook" /></a>-->
            <a href="<?php echo $website_domain.'/account/auth.php?pl=facebook'; ?>" class="btn facebook">Login with Facebook</a>
            <a href="<?php echo $website_domain.'/account/auth.php?pl=twitter'; ?>" class="btn twitter">Login with Twitter</a>
            <a href="<?php echo $website_domain.'/account/auth.php?pl=linkedin'; ?>" class="btn linkedin">Login with Linkedin</a>
            <a href="<?php echo $website_domain.'/account/auth.php?pl=google'; ?>" class="btn gplus">Login with Google+</a>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

你应该添加

onclick="submitMyForm()"

到提交按钮,然后在名为 submitMyForm 的函数中实现ajax操作。

如果您不确定ajax或不想使用字段,您可以使用隐藏的iframe并使您的&lt; form&gt;那里的目标点。通过这种方式,您可以像往常一样获得提交的信息,但不会重新加载页面。