I am trying to use jquery validate plugin on my 5 questions quiz form. But I have issue with how to display the validated error message for require field.
My form is something like this:
<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>
My validate.js:
$(document).ready(function() {
var form = $("#quiz");
form.validate({
errorPlacement: function(error, element) {
error.insertAfter(x); // what should x be?
}
});
});
I would like to what should be used to replace 'x' in the errorPlacement for my validate error message to show up in the of my form?
Thank you.