Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
AJAX results radio button verification

I have an ajax call that returns html. This html includes two radio buttons. When the page is submitted, I need to verify the ajax results have had a radio selected. On initial page load, I have no problem, it is when I try to verify ajax results that it fails on the verification.

This is the code I am looking to implement :

 $("body").on("click", "address_type", function submitPage(event) { 
  var selectedVal = "";
  var selected = $("input[type='radio'][name='address_type']:checked");
  if (selected.length > 0) {
    selectedVal = selected.val();
  }else{
    alert('Check address type');
    event.preventDefault();
  }
});

The radio I am looking to verify (returned by ajax):

<label class="container">Radio No
<input name="address_type" value="commercial" type="radio" aria-required="true" id="Address_commercial">
<span class="checkmark"></span>
</label>

<label class="container" >Radio Yes
<input name="address_type" value="residential" type="radio" aria-required="true" id="Address_residential">
<span class="checkmark"></span>
</label>

The verification function submitPage is called by :

<div class="continue"  style="color:blue;">
<input type="submit" class="form-button" value="submit" onclick="submitPage(event)"/>
</div>

On the initial page load, is straight forward to verify, but when I return results from an ajax call, the verification is not performed correctly. Tried adding the $("body").on("click" but it does not seems to work.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda