2013-11-04 60 views
0

我有一個小問題。我想重新定位我的密碼檢查錯誤消息。我想在我的表單按鈕下看到消息。所以我試圖用a設置errorLabelContainer,但它不工作,有人能幫我找出問題嗎?JQuery重定位錯誤消息

HTML:

<form name="f" id="f" action="<%= request.getContextPath() %>/setpassword" method="POST"> 
    <table> 
     <tr> 
      <td> 
       <label for="password">Passwort</label>:&nbsp;&nbsp; 
      </td> 
      <td> 
       <input type="password" id="password" name="password" size="20" /> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <label for="password_again">Passwort wiederholen</label>:&nbsp;&nbsp;</td> 
      <td> 
       <input class="left" type='password' id="password_again" name="password_again" size="20" /> 


      </td> 
     </tr> 

     <tr> 
      <td colspan="2">&nbsp;</td> 
     </tr> 
     <tr> 
      <td colspan='2' align="center"> 
       <input name="submit" type="submit" value="submit" /> 
      </td> 
     </tr> 
    </table> 

    <div class="errorMsg"> </div> 
</form> 

JQuery的:

$("#f").validate({ 
     rules: { 
     password: { 
       required: true, 
       minlength: 8 
     }, 
     password_again: { 
      equalTo: "#password" 
     } 
     }, 
     messages: { 

     password: { 
      required: "Bitte geben Sie Ihr Passwort zwei mal ein.", 
      minlength: "Ihr Passwort muss aus mindestens 8 Zeichen bestehen." 
      }, 

     password_again: { 
      required: "Bitte geben Sie Ihr Passwort zwei mal ein.", 
      equalTo: "Ihre Eingabe muss gleich sein." 
      } 
     }, 
     errorLabelContainer: '#errorMsg', 
     wrapper: 'li' 

}); 

感謝所有幫助:)

+0

你可以用一些CSS來做到這一點,你試過嗎? – Ahmad

回答

2

<div>errorMsg,但是您正在使用的元素搜索IDerrorMsg