php - How to Display errors within drop down login box without refresh and reselecting login option -


i've drop down login box works great when input expected. had separate login page, if password etc incorrect message displayed.

currently drop down login, if there error page refreshes, drop down goes it's inactive state (hiding) , error visible when select login again.

for example:

if put in wrong user name , click submit. page on refreshes , looks normal. click login box again, form drops down error message username not valid.

the validation done via php , drop down through jquery.

can me achieve perfect drop down login box? :) i'd there no visible refresh @ all, box stay down when error input , disappear when logged in correctly or when cancelled.

the jquery function:

//displaying login dropdown menu $(document).ready(function(){     $('#logintrigger').click(function(){         $(this).next('#logincontent').slidetoggle();     }) }); 

thanks

edit:

updated form code requested

<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> 


Comments