I am using jQuery Validation plugin for a form. When the form is not validated, I am getting the correct error message, I would just like to place it in another location.
Right now the error label is showing up under the first checkbox label(Check 1). I would like to appear in the #messageBox div.
This is what I thought would work....but it doesn't :(
html:
<div class="form_row">
<div class="buttonColumn">
<label><input type="checkbox" name="program[]" class="isChecked error">Check 1</label>
<label><input type="checkbox" name="program[]" class="isChecked error">Check 2</label>
<label><input type="checkbox" name="program[]" class="isChecked error">Check 3</label>
<label><input type="checkbox" name="program[]" class="isChecked error">Check 4</label>
</div>
<div id="messageBox"></div>
jQuery:
$('#custom_form').validate({
rules: {
"program[]": {
required: true,
minlength: 1,
},
errorPlacement: function(error, element) {
if (element.attr("program[]") == "program[]") {
error.appendTo('#messageBox');
}
},
messages: {
"program[]": "Please choose a program.",
}
});