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

307
Views
Alerta de javascript que no funciona en dispositivos móviles.

Tengo un código de alerta de javascript que muestra una alerta si una casilla de verificación no está marcada si un usuario intenta hacer clic en el botón de confirmación y funciona bien en el escritorio pero en la vista/dispositivos móviles, no funciona y traté de agregar touchstart , touch , touchend el javascript al lado de hacer clic, pero nada parece funcionar cuando lo pruebo en mi móvil, mi código está a continuación si alguien puede ayudar, por favor.

 $(document).ready(function() { $('#confirmcheckout').on('click touchend', function() { if ($('#terms-condition').prop('checked') == true) { } else { alert("To proceed you must accept the terms.") } }); })

Gracias de antemano

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Supongo que 'hacer clic en el extremo táctil' podría dispararse dos veces en el móvil.

Esto podría ayudar:

 $(document).ready(function() { $('#confirmcheckout').on('click touchend', function(event) { event.stopPropagation(); event.preventDefault(); if ($('#terms-condition').prop('checked') == true) { } else { alert("To proceed you must accept the terms.") } }); })

EDITAR: Otra posible solución:

 $(document).ready(function() { $('#confirmcheckout').on('touchend click', function(event) { if(event.type == 'touchend') { $(this).off('click'); } if ($('#terms-condition').prop('checked') == true) { } else { alert("To proceed you must accept the terms.") } }); })

(si el extremo táctil funciona, elimine el clic)

about 4 years ago · Juan Pablo Isaza Report

0

Creo que lo acabo de resolver con el siguiente código.

 <input id="terms-condition" type="checkbox" onclick="validate()" name="terms_condition" value="1" required="required" class="custom-control-input" {!! set_checkbox('terms_condition', '1') !!}> <button class="checkout-btn btn btn-primary btn block btn-lg" onclick="validate()" data-attach-loading="disabled" data-checkout-control="confirm-checkout" data-request-form="#checkout-form" id="confirmcheckout">Confirm</button> function validate() { if (document.getElementById('terms-condition').checked) { alert("Thank you for agreeing to the terms"); } else { alert("To proceed, you must accept the terms."); } }

Parece que funciona tanto en la vista móvil como en la de escritorio.

about 4 years ago · Juan Pablo Isaza 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!