1
jQuery 유효성 검사에서 생성 된 오류 메시지를 어디에 넣을 지 사용자 정의하려고합니다. 그것이 작동하지 않는 몇 가지 이유를 들어jquery validation errorPlacement가 작동하지 않습니다.
<div>
<form action="#">
<input type="text" name="a" id="a">
</form>
</div>
<div id="restErrorDate" class="restErrorDate" style="border:1px solid blue;"></div>
: 여기
$('document').ready(function(){
$('form').validate({
rules: {
a: {required:true, minlength:2}
},
messages: {
a: {required: "enter your name!"}
},
errorPlacement: function(error, element) {
if(element.attr('name' == 'a')){
error.appendTo($('#restErrorDate'));
}
},
debug:true
});
$('#a').blur(function(){
$("form").validate().element("#a");
});
});
는 HTML입니다 : 나는 다음과 같은 코드가 있습니다. 도움을 위해 미리 감사드립니다 ...이 작은 일이 나를 오랫동안 일하게 해왔습니다.
http://jsfiddle.net/mmw562/S7AKK/38/
좋은 다음은 jsfiddle입니다! 폼 요소 안에'div # restErrorDate'를 넣으면 더 좋습니다. 양식 끝 태그 바로 앞에 이렇게하면 입력 요소가 유효 해지면 오류 메시지가 사라집니다. – Mori