0
I have a problem, in my view the logic is correct, however it is not working, I have a select that has to be checked and if it is selected certain option it opens another select, in that other select depending on the information selected it validates if there is something written in the input field, the error is that it is not checking if there is something in that input and it seems that it jumps that if and already goes to Else.
Follow the code I’m trying to:
var aoption = document.getElementById("options").value;
var aopcDemaisTemAniver = ['Aniversario de Nascimento', 'Aniversario de Namoro', 'Aniversario de Casamento', 'Aniversario de Mêsversario', 'Outras Opções'];
var aoptionAni = document.getElementById("options2").value;
var ademaisOpcSex = ['Aniversario de Nascimento', 'Aniversario de Mêsversario'];
var ainput6 = document.getElementById("IdadePeriodo3").val()== null;
if(aoption == 'Aniversario' && !aopcDemaisTemAniver.includes(aoptionAni)){
swal({
title: "Ops.. Algo está errado !",
text: "Para finalizar a compra é necessario selecionar qual o tipo de Aniversario.",
button: "Continuar",
});
document.formMonteCaixa.options2[0].focus();
}else if(aoption == 'Aniversario' && !aopcDemaisTemAniver.includes(aoptionAni) && !ademaisOpcSex.includes(aoptionAni) && ainput6.length<1){
swal({
title: "Ops.. Algo está errado !",
text: "Para finalizar a compra é necessario informar o Idade / Periodo.",
button: "Continuar",
});
document.formMonteCaixa.IdadePeriodo3[0].focus();
}else{
alert(ainput6);
document.getElementById('BlocoDeEnvioEmailPag').style.display = 'block';
}
<select id="options" name="options" class="cc-selector" onchange="optionCheck()">
<option value="Selecione o Tema:" disabled selected>Selecione o Tema:</option>
<option value="Aniversario">Aniversário</option>
<option value="Pedido Casamento">Pedido Casamento</option>
<option value="Gravidez">Gravidez</option>
<option value="Nascimento">Nascimento</option>
<option value="Dia das Mães / Pais">Dia das Mães / Pais</option>
<option value="Outros">Outros</option>
</select>
<div id="hiddenDiv" class="Aniversario" style="display:none;">
<select id="options2" name="options2" onchange="optionCheck()">
<option value="Aniversario" disabled selected>Aniversário de:</option>
<option value="Aniversario de Nascimento">Aniversário de Nascimento</option>
<option value="Aniversario de Namoro">Aniversário de Namoro</option>
<option value="Aniversario de Casamento">Aniversário de Casamento</option>
<option value="Aniversario de Mêsversario">Aniversário de Mêsversario</option>
<option value="Outras Opções">Outras Opções</option>
</select>
</div>
<div id="hiddenDiv4_1" class="OpçõesAniversarioComSex cc-selector" style="display:none;">
<div class="ModeloCaixaBloco6Col1 ModeloCaixaBloco6Col1K">
<input type="text" id="IdadePeriodo3" name="IdadePeriodo3" placeholder="Idade / Periodo" onblur="optionCheck(this);">
</div>
</div>
Thank you very much, I entered this and made a small change in my if e agr is working, if anyone needs it this way: (aoption == 'Anniversary' && ademaisOpcSex.includes(aoptionAni) && ainput6 == true)
– RonaldoM
@dvd did not know this icon , that cool :)
– Matheus Miranda
Oh yes, about the icons, you can copy from https://getemoji.com/ and paste here rs
– Sam
@dvd vi agora, you forgot to mention me, so I don’t get the notifications.
– Matheus Miranda
@dvd because in developer mode (F12) I cannot see the code of the icon ? Only drawing appears. How bizarre !!!
– Matheus Miranda
@Matheusmiranda Well, man, I don’t know much about it... it seems like an image but it’s not, it’s like it’s some character
– Sam
@dvd I think I’ll ask this question here at stackoverflow
– Matheus Miranda
@Matheusmiranda I thought about doing it a few days ago, but I let it go
– Sam