1
I have a form using step Wizard as the link below:
https://bootsnipp.com/snippets/j6rkb
It works correctly, but I saw that the field validation only works for fields input. How could I validate also combobox fields? See below his jquery:
<script>
$(document).ready(function () {
var navListItems = $('div.setup-panel div a'),
allWells = $('.setup-content'),
allNextBtn = $('.nextBtn');
allWells.hide();
navListItems.click(function (e) {
e.preventDefault();
var $target = $($(this).attr('href')),
$item = $(this);
if (!$item.hasClass('disabled')) {
navListItems.removeClass('btn-success').addClass('btn-default');
$item.addClass('btn-success');
allWells.hide();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allNextBtn.click(function () {
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
curInputs = curStep.find("input[type='text'],input[type='url']"),
isValid = true;
$(".form-group").removeClass("has-error");
for (var i = 0; i < curInputs.length; i++) {
if (!curInputs[i].validity.valid) {
isValid = false;
$(curInputs[i]).closest(".form-group").addClass("has-error");
}
}
if (isValid) nextStepWizard.removeAttr('disabled').trigger('click');
});
$('div.setup-panel div a.btn-success').trigger('click');
});
</script>
The select would be that:
<select name="Estado" class="form-control" required="required">
<option value="">Selecione</option>
<option value="RJ">Rio de Janeiro</option>
<option value="SP">São Paulo</option>
</select>
The complete code is found in the link I passed above, because I am copying faithfully as developed by the author.
When you talk combobox is referring to a select right?
– João Pedro Schmitz
Hello John, this... is a simple Bootstrap select.
– user24136
I corrected the title with my post ;)
– user24136
Show, I didn’t understand the combobox part.
– João Pedro Schmitz
I believe it would be nice if you put the html select to facilitate the understanding of the question.
– João Pedro Schmitz
Right. I put the select code in the post.
– user24136
From the moment you build a select, it is assumed that the options are valid, so validate option that offers in select I find unnecessary, or am I mistaken?
– user76097
I believe the correct question would be
verificar se foi selecionado alguma opção em um select
– user76097
Fox, if any answer has solved your problem you can mark as accepted by clicking the green V on the side of the chosen points. Or, if you want, you can leave it open for a while if you want more alternatives, but it is good that after it is resolved you mark some to close the subject. Learn more in "How and why to accept an answer".
– João Pedro Schmitz
Hello John. Done ;) Thank you!
– user24136