I have the following HTML code which shows me a text box:
<div class="form-group empresa_rfc">
<label for="empresa_rfc" class="col-sm-2 control-label"><p class="text-left">RFC: (*)</p></label>
<div class="col-sm-3">
<input type="text" class="form-control" id="empresa_rfc" name="empresa_rfc" placeholder="RFC" >
</div>
</div>
I am using Bootrap 3.3.7. And then I have this validation with the Jquery Validate Plugin from link
$("#form_empresa").validate({
focusCleanup: true,
rules: {
empresa_rfc: { required: true }
},
invalidHandler: function(event, validator){
var errors = validator.numberOfInvalids();
if (errors){
var message = errors == 1
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
swal({
title:"Error:",
text: message,
type: "error",
allowOutsideClick: false,
confirmButtonColor: '#d33',
confirmButtonText: "Corregir"
});
//console.log(message);
}
}
});
The previous code shows me and indicates the field that has not been completed, and shows me a alert
indicating the errors contained in 'message'. My question is, how can I affect the
<div class="form-group empresa_rfc">
and add the 'has-error' class of Bootstrap so you can point that field in specific? Specifically, it should look like this:
<div class="form-group empresa_rfc has-error">