0
I am trying to validate a drop-down list with jquery-validation and 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">
Section that should carry out the 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 cannot be zero