我使用Labelify插件在我的文本字段中添加一个浅灰色的标签。该插件将title属性用于内部文本。我还使用了验证插件来验证特定的字段。
当验证失败时,验证器会生成一个错误,该错误也是从该字段的title属性中获得的。我该如何为该字段生成自定义错误,而不是自动获取title属性?
发布于 2011-03-11 13:39:27
试试这样的东西
<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
发布于 2011-03-11 13:41:11
https://stackoverflow.com/questions/5269348
复制相似问题