I'm using this form validation with text fields. However, I'm not getting it at all with checkboxList. Is there any way to do this? Follow the code below.
function form_validation() {
$("#aspnetForm").validate({
errorElement: 'span',
errorClass: 'help-block',
rules: {
ctl00$ContentPlaceHolder1$txtDataInicioEmissao: {
required: true
},
ctl00$ContentPlaceHolder1$txtDataFimEmissao: {
required: true
},
ctl00$ContentPlaceHolder1$chkLstOrigem: {
checkrequired: true
}
},
messages: {
ctl00$ContentPlaceHolder1$txtDataInicioEmissao: {
required: "<%= Resources.UIResource.PreenchaOcampo %>"
},
ctl00$ContentPlaceHolder1$txtDataFimEmissao: {
required: "<%= Resources.UIResource.PreenchaOcampo %>"
}
},
highlight: function (element) { // entradas de erro do hightlight
$(element)
.closest('.form-group').removeClass('has-success').addClass('has-error'); // definir a classe de erro no form-group
},
unhighlight: function (element) { // reverter a mudança feita pelo hightlight
$(element)
.closest('.form-group').removeClass('has-error'); // definir a classe de erro no from-group
}
});
return true;
}