This looks very simply, but I can't figure it out. I'm using the jquery validate plugin. I'm trying to validate <input name=first>
and <input name=second>
to output the error messages into:
<span id="errNm2"></span> <span id="errNm1"></span>
I already started writing the errorPlacement: which is where you customize your error message location.
How can I put the errors message in those <span>
?
$(document).ready(function () {
$('#form').validate({
errorPlacement: function(error, element) {
error.append($('.errorTxt span'));
},
rules,
});
<input type="text" name="first"/>
<input type="text" name="second"/>
<div class="errorTxt">
<span id="errNm2"></span>
<span id="errNm1"></span>
</div>