2008-11-21 69 views

回答

14

使用errorPlacement属性的jQuery验证电话,为J库珀建议:

$(...).validate({ 
    errorPlacement: function(error, element) { 
     error.insertBefore(element); 
    } 
}); 

和CSS样式的错误(在你的样式表,或者单个元素):

label.error { 
    /* Move the error above the input element. */ 
    position: absolute; 
    line-height: 1.5em; 
    margin-top: -1.5em; 

    background-color: red; 
    color: white; 
    padding: 0 2px; 
} 
+2

对于jQuery位:应该使用insertBefore()而不是before()。谢谢! – neezer 2009-06-19 15:43:52