I'm trying to validate a drop-down list with jquery-validation and I could not, I took an example and tried to adapt my need, I did this:
The form that triggers validation:
<form class="form-horizontal" id="frmFaseObrigatoria" action="" method="post">
Excerpt that should perform validation:
$(document).ready(function() {
$("#frmFaseObrigatoria").validate({
rules: {
IdTipoFase1: {
required: true,
},
iOrdem: {
required: true,
},
},
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
errorElement: 'span',
errorClass: 'help-block',
errorPlacement: function(error, element) {
if (element.parent('.input-group').length) {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
},
// FUNÇÃO ENVIADA APÓS VALIDAÇÃO
submitHandler: function(form) {
DlgInserirFaseObrigatoria();
}
});
});
What I tried to do:
rules: { IdTipoFase1: { valueNotEquals: 0 }, IdTipoFase1: { valueNotEquals: "Informe um valor" },
The value of my drop-down can not be zero