0

我有一个下拉登录框,当输入符合预期时效果很好。以前我有一个单独的登录页面,如果密码等不正确,则会显示消息。

当前使用下拉登录,如果页面刷新出现错误,下拉将返回到其非活动状态(隐藏),并且仅当您再次选择登录时错误才可见。

例如:

如果我输入错误的用户名并单击提交。我所在的页面刷新并且看起来很正常。然后我再次单击登录框,表单下拉,错误消息用户名无效。

验证通过 PHP 完成,下拉通过 jQuery 完成。

谁能帮我实现完美的下拉登录框?:) 我希望它根本没有可见的刷新,当输入错误时该框保持关闭状态,并且仅在正确登录或取消时才消失。

jQuery函数:

//Displaying the login dropdown menu
$(document).ready(function(){
    $('#loginTrigger').click(function(){
        $(this).next('#loginContent').slideToggle();
    })
});

谢谢

编辑:

根据要求使用表单代码更新

<nav class = "memberHeaderArea">
        <ul>
            <li id="login">
                <a id="loginTrigger" href="#">Login<span class="unlock icon"></span></a>

                <div id="loginContent">

                    <?php if(empty($errors) === false){
                        echo '<p>' .implode('</p<p>', $errors).'</p>';
                    }
                    ?>

                    <form method="post" action="" id="ourLoginFormID_JS">
                        <div class="ourContactFormElement2">
                            <label for="username">Username:</label>
                            <input type="text"  name="username" autocomplete="off" class="required" value="<?php if(isset($_POST['username'])) echo htmlentities($_POST['username']); ?>"  />
                        </div>

                        <div class="ourContactFormElement2">
                            <label for="password">Password:</label>
                            <input type="password" name="password" autocomplete="off" class="required"/>
                        </div>

                        <div class="ourContactFormElement2">
                            <label> &nbsp; </label>
                            <input type="submit" name="submit" value="Login!" />
                        </div>
                    </form>

                    <form action="confirmRecovery.php">
                        <input type="submit" name="forgotPass" id="forgotPass" value="Forgotten Password?">
                    </form>

                </div>
            </li>

            <li>
                <a href="userRegister.php">Register<span class="adduser icon"></span></a>
            </li>


        </ul>
    </nav>
4

0 回答 0