This looks very simply, but I can\'t figure it out. I\'m using the jquery validate plugin. I\'m trying to validate and
What you should use is the errorLabelContainer
jQuery(function($) {
var validator = $('#form').validate({
rules: {
first: {
required: true
},
second: {
required: true
}
},
messages: {},
errorElement : 'div',
errorLabelContainer: '.errorTxt'
});
});
.errorTxt{
border: 1px solid red;
min-height: 20px;
}
If you want to retain your structure then
jQuery(function($) {
var validator = $('#form').validate({
rules: {
first: {
required: true
},
second: {
required: true
}
},
messages: {},
errorPlacement: function(error, element) {
var placement = $(element).data('error');
if (placement) {
$(placement).append(error)
} else {
error.insertAfter(element);
}
}
});
});
#errNm1 {
border: 1px solid red;
}
#errNm2 {
border: 1px solid green;
}