<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">使用validate进行表单验证时会出现error显示位置非所要求位置的现象,此时的解决方法是:</span>
1.所需要显示error message 的位置定义好无内容的div,并通过设置宽高"占位"(此时可能会用到position:absolute);
2.使用errorPlacement判断哪个error message 放在什么位置,例如,
errorPlacement: function(error, element) {
if(element.attr("id")=="shoujihaoma"){
error.appendTo("#error_message_1");
}
}.
以上就会把输入框id为shuojihaoma的error message 显示在id为error_message_1的位置上.
除了appendTo添加到容器内,还可以使用insertAfter添加到容器后.