From e1ba78edb893ff8d04bd2a7788c28d5ff9603827 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 3 Jul 2026 00:12:03 -0500 Subject: [PATCH] =?UTF-8?q?fix(otp):=20pegar=20c=C3=B3digo=20completo=20di?= =?UTF-8?q?stribuye=20d=C3=ADgitos=20en=20todos=20los=20campos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- verificar.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/verificar.php b/verificar.php index 0040856..575970e 100644 --- a/verificar.php +++ b/verificar.php @@ -424,7 +424,17 @@ let _reenvioTimer = null; // ── OTP input navegación automática ────────────────────────────────── document.querySelectorAll('.otp-digit').forEach((inp, i, arr) => { inp.addEventListener('input', () => { - inp.value = inp.value.replace(/\D/g, '').slice(-1); + const val = inp.value.replace(/\D/g, ''); + if (val.length > 1) { + // Pega múltiples dígitos (mobile/autofill) + const digits = val.slice(0, 6); + arr.forEach((d, j) => { d.value = digits[j] || ''; }); + const last = Math.min(digits.length - 1, arr.length - 1); + arr[last].focus(); + if (otpCompleto()) verificarOtp(); + return; + } + inp.value = val; if (inp.value && i < arr.length - 1) arr[i + 1].focus(); if (otpCompleto()) verificarOtp(); }); @@ -435,7 +445,9 @@ document.querySelectorAll('.otp-digit').forEach((inp, i, arr) => { e.preventDefault(); const txt = (e.clipboardData || window.clipboardData).getData('text').replace(/\D/g,'').slice(0,6); arr.forEach((d, j) => { d.value = txt[j] || ''; }); - if (txt.length === 6) { arr[5].focus(); verificarOtp(); } + const last = Math.min(txt.length - 1, arr.length - 1); + if (last >= 0) arr[last].focus(); + if (txt.length === 6) verificarOtp(); }); });