내 5 가지 질문에 jquery validate plugin을 사용하려고합니다. 하지만 난 필드에 대한 유효성을 검사 한 오류 메시지를 표시하는 방법에 문제가 있습니다.Jquery가 오류 메시지 배치 위치를 확인합니다.
<form id="quiz">
<table width="100%">
<tbody>
<tr id="qntr">
<td id="qntd">My question 1</td>
<!-- if field is empty, validate error message to appear over here -->
</tr>
<tr id="anstr">
<td id="anstd">
<table><tr>
<td>Choice 1</td>
<td>Choice 2</td>
<td>Choice 3</td>
</tr></table>
</td>
</tr>
<tr id="qntr">
<td id="qntd">My question 2</td>
<!-- if field is empty, validate error message to appear over here -->
</tr>
<tr id="anstr">
<td id="anstd">
<table><tr>
<td>Choice 1</td>
<td>Choice 2</td>
<td>Choice 3</td>
</tr></table>
</td>
</tr>
...
</tbody>
</table>
</form>
내 validate.js :
내 양식이 같은 것입니다
$(document).ready(function() {
var form = $("#quiz");
form.validate({
errorPlacement: function(error, element) {
error.insertAfter(x); // what should x be?
}
});
});
싶습니다 내 유효성 검사 오류에 대한 'X'는 errorPlacement에 대체하는 데 사용되어야 하는지를 양식의 에 표시 할 메시지가 있습니까?
감사합니다.
두 개 이상의 요소에 동일한 ID를 사용하지 말 것을 강력히 권합니다. 아래 업데이트 된 답변을 확인하십시오! – dejavu