It appears to me that the jquery-validation showErrors blocks the action of highlight and unhighlight.
In html I have a required form-group:
<form id="ValidationForm" method="post" class="form-horizontal" role="form" novalidate="novalidate">
<div class="form-group required">
<label class="col-xs-3 control-label" for="Letters">Letters</label>
<div class="col-xs-9 controls">
<input class="form-control input-md" id="Letters" name="Letters" type="text" placeholder="Letters" />
</div>
</div>
<div class="col-xs-4">
<input id="btnSave" class="btn btn-default" type="submit" value="Save Changes" name="btnSave">
</div></form>
In javascript I have rules for the validator defined:
var rules = {
rules: {
"Letters": { required: true }
},
submitHandler: function (form) {
$('#btnSave').prop("disabled", true);
form.submit();
},
highlight: function (element, errorClass) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function (element, errorClass) {
$(element).closest('.form-group').removeClass('has-error');
},
showErrors: function(errorMap, errorList) {
$.each(this.successList, function(index, value) {
return $(value).popover("hide");
});
return $.each(errorList, function(index, value) {
var _popover;
_popover = $(value.element).popover({
trigger: "manual",
placement: "auto",
content: value.message,
template: "<div class=\"popover\"><div class=\"arrow\"></div><div class=\"popover-inner\"><div class=\"popover-content\"><p></p></div></div></div>"
});
_popover.data("bs.popover").options.content = value.message;
return $(value.element).popover("show");
});
}
};
$("#ValidationForm").validate(rules);
If I remove the showErrors and press the submit button the form-group has the "has-errors" class added and the input border is displayed as red. When showErrors is added, this highlight functionality disappears. Any ideas why?