2011-03-11 100 views
1

我使用Labelify插件在我的文本字段中有一個淺灰色標籤。該插件使用title屬性作爲內部文本。我還使用驗證插件來驗證該特定字段。使用jQuery Labelify + jQuery驗證

驗證失敗時,驗證器會生成一個錯誤,它也會從該字段的title屬性中獲取錯誤。我將如何爲該字段製作自定義錯誤,而不是自動獲取title屬性?

+0

可能你請添加一個代碼 – 2011-03-11 05:37:22

回答

1

嘗試這樣的事情

<tr> 

    <td><input type="text" name="name" size="30"/> 

    <p class="error"></p> 

    </td> 

</tr> 

而且在你驗證部分

$('#category').validate({ 

    rules:{name: {required: true}}, 

    messages: {name: "Category name is required"},  

    errorPlacement: function(error, element){ 

      $(element).each(function(){ 

      $(this).parent('td').find('p.error').html(error); 

     }); 

}}) 

#category是表格ID