0
I made some inputs in text format and then created a function in javascript to check empty fields of the same, but when I press the button next it shows the error(the normal sweetalert box describing the error as expected)but then it moves on to the next normal page to give false, follow the code:
<div class="row">
<div class="form-group col-md-6">
<label for="endereco-aluno">Endereço: <font color="red">*</font></label>
<input type="text" class="form-control" id="endereco-aluno">
</div>
<div class="form-group col-md-6">
<label for="bairro-aluno">Bairro: <font color="red">*</font></label>
<input type="text" class="form-control" id="bairro-aluno">
</div>
</div>
this is the normal html the button I made to check the fields was this:
<button class="forward" id="botaoProximo2" style="margin-top: 15px; float: right;"
onclick="SOLICITAR_ESTAGIO.verificaCamposDadosEstudante()">Próximo</button>
And that was the Jedi:
verificaCamposDadosEstudante: function () {
var endereco_aluno = $("#endereco-aluno").val();
var bairro_aluno = $("#bairro-aluno").val();
if (endereco_aluno == '') {
swal("Oops", "Para avançar você precisar informar o Endereço.", "error");
return false;
} else if (bairro_aluno == '') {
swal("Oops", "Para avançar você precisar informar a Bairro.", "error");
return false;
}
},
fields with READONLY are already filled in automatically and no verification is required
Your button is inside a form?
– André Adriano
No, it’s all inside a joint
– Arthur Felipe
Then you advance the page with another event or within the
verificaCamposDadosEstudante
?– André Adriano
onclick="SOLICITAR_ESTAGIO.checkCamposDadosEstudante()", in this event, I want to know if the problem is by the button class="forward" and so it might not be returning false
– Arthur Felipe
in onclick I do the checks of the empty fields and if I am sending the sweetalert and consequently the false, I will have to put the class of the foward button inside that javascript ? I don’t understand what’s going on
– Arthur Felipe
So you use some plugin to control this page? Because it seems that there is some event in that same button that runs along with its validation function
– André Adriano
for me what I think is happening is the foward button shitting everything
– Arthur Felipe
no problem at all in the part you reported, I put a reply with a functional example.
– HudsonPH
post code related to SOLICITAR_ESTAGIO
– HudsonPH
There is no way javascript has more than 1300 lines and here it does not allow
– Arthur Felipe