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(); }); });