This question already has answers here:
Validation plugin is not validating all fields
(2 answers)
Bootstrap & JQuery Validate Form Validation
(3 answers)
jQuery validation plugin not functioning
(3 answers)
Closed 2 years ago.
I'm using Jquery validation plugin, everything work fine but when i try to validate the check box i got an error:
TypeError: b is undefined
here's my bootstrap checkbox script:
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" required> I agree to the <a href="#">terms</a>
</label>
</div>
</div>
and here's the jquery validation that i used:
$("#formRegister").validate({
errorElement: "span",
errorClass: "help-block",
highlight: function (element, errorClass, validClass) {
// Only validation controls
if (!$(element).hasClass('novalidation')) {
$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
}
},
unhighlight: function (element, errorClass, validClass) {
// Only validation controls
if (!$(element).hasClass('novalidation')) {
$(element).closest('.form-group').removeClass('has-error').addClass('has-success');
}
},
errorPlacement: function (error, element) {
if (element.parent('.input-group').length) {
error.insertAfter(element.parent());
}
else if (element.prop('type') === 'radio' && element.parent('.radio-inline').length) {
error.insertAfter(element.parent().parent());
}
else if (element.prop('type') === 'checkbox' || element.prop('type') === 'radio') {
error.appendTo(element.parent().parent());
}
else {
error.insertAfter(element);
}
}