2012-09-07 233 views
0

我的问题是,当其具有错误消息,并且用户试图更改的选项卡,然后再返回到注册我的登记表的错误信息仍然存在又该如何清除/从onblur事件删除值当我更改标签并且再次点击注册链接时,我确实能够删除错误消息吗?标签更改

<script src="http://code.jquery.com/jquery-1.8.1.js"></script> 
    <script> 
     $(function() {   
      var tabContainers = $('section.tabs > article'); 
      tabContainers.hide().filter('#login').show(); 

      $('.ultabs a').click(function() { 
       tabContainers.hide(); 
       tabContainers.filter(this.hash).show(); 
       $('.ultabs a').removeClass('selected'); 
       $(this).addClass('selected'); 
       return false; 
      }); 
     }); 
     function check_email() { 
      var email=$("#textEmail").val(); 
      $.ajax(
      { 
       type:"POST", 
       url:"register.php", 
       data: { 
       'email': email 
       }, 
       success:function(msg) { 
        $("#checkEmail").html(msg); 
       } 
      }); 
      return false; 
     } 
     function check_password() { 
      var pass=$("#textPassword").val(); 
      $.ajax(
      { 
       type:"POST", 
       url:"register.php", 
       data: { 
       'pass': pass 
       }, 
       success:function(msg) { 
        $("#checkPassword").html(msg); 
       } 
      }); 
      return false; 
     } 
    </script> 

<nav id="siteNav"> 
    <h1>Navigation</h1> 
    <ul class="ultabs"> 
     <li><a href="#login">Login</a></li> 
     <li><a href="#register">Register</a></li> 
    </ul> 
</nav> 
<section id="siteContent" class="tabs"> 
    <h1>Section</h1> 
    <article id="login"> 
     <h1>Login</h1> 
     <table> 
      <tr> 
       <td class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>E-mail:</td><td><input type="email"></td> 
      </tr> 
      <tr> 
       <td class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>Password:</td><td><input type="password"></td> 
      </tr> 
      <tr> 
       <td colspan="2"><input type="button"></td> 
      </tr> 
     </table> 
    </article> 
    <article id="register"> 
     <h1>Register</h1> 
     <table> 
      <tr> 
       <td class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>Name:</td><td><input type="text"></td> 
      </tr> 
      <tr> 
       <td id="checkEmail" class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>E-mail:</td><td><input id="textEmail" type="email" onblur="return check_email()"></td> 
      </tr> 
      <tr> 
       <td id="checkPassword" class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>Password:</td><td><input id="textPassword" type="password" onblur="return check_password()"></td> 
      </tr> 
      <tr> 
       <td class="message" colspan="2"></td> 
      </tr> 
      <tr> 
       <td>Re-type:</td><td><input type="password"></td> 
      </tr> 
      <tr> 
       <td colspan="2"><input type="button"></td> 
      </tr> 
     </table> 
    </article> 
</section> 
+0

的变化td? – ManseUK

+0

TD有一类=“消息” –

回答

0

可以清除哪里是你的代码,增加了错误信息的标签

$('.ultabs a').click(function() { 
    $('.message').html(''); 
    // the rest of your code 
}); 
+0

它的工作原理谢谢主席先生。 –