Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Cómo verificar si ambos botones de radio no están marcados

Estoy tratando de validar esos botones de opción y notificar al usuario si ambos están desmarcados. Mi función RadioValidation() no funciona, ¿cómo puedo solucionarlo? ¡Gracias!

 function RadioValidation() { var buttons = document.querySelectorAll('input[name="shipmethod"]:checked'); for (var i = 0; i < buttons.length; i++) { if (!buttons[i].checked) { alert("NOT CHECKED") } } }
 <label class="radiner"> PickUp <input type="radio" name="shipmethod" value="PickUp" required> <span class="checkmark"></span> </label> <label class="radiner"> Delivery <input type="radio" name="shipmethod" value="Delivery" required> <span class="checkmark"></span> </label> <button class="btn txt-center" type="submit" id="checkout" onclick="RadioValidation()">Payment</button>

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Prueba esto

 function RadioValidation() { var buttons = document.querySelector('input[name="shipmethod"]:checked'); if(buttons) console.log(buttons.value); else alert('Nothing selected'); }
 <label class="radiner"> PickUp <input type="radio" name="shipmethod" value="PickUp" required> <span class="checkmark"></span> </label> <label class="radiner"> Delivery <input type="radio" name="shipmethod" value="Delivery" required> <span class="checkmark"></span> </label> <button class="btn txt-center" type="submit" id="checkout" onclick="RadioValidation()">Payment</button>

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!