</> ConvertAtlas Developer Tools
Bootstrap 5 · Intermediate

OTP Auto-Advance Input

A 4-box code input that auto-advances and supports backspace.

Requires Bootstrap 5. Add the CDN tags below to your page (styles in <head>, scripts before </body>). The downloaded file already includes them.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="card border-0 shadow-sm text-center" style="max-width:340px"><div class="card-body">
  <h6 class="fw-bold mb-3">Enter code</h6>
  <div class="d-flex justify-content-center gap-2" id="otpWrap">
    <input class="form-control text-center fw-bold px-0" maxlength="1" style="width:44px" inputmode="numeric">
    <input class="form-control text-center fw-bold px-0" maxlength="1" style="width:44px" inputmode="numeric">
    <input class="form-control text-center fw-bold px-0" maxlength="1" style="width:44px" inputmode="numeric">
    <input class="form-control text-center fw-bold px-0" maxlength="1" style="width:44px" inputmode="numeric">
  </div>
  <small class="text-secondary mt-2 d-block" id="otpOut">Waiting…</small>
</div></div>
var ins=document.querySelectorAll('#otpWrap input'),out=document.getElementById('otpOut');
ins.forEach(function(inp,i){inp.addEventListener('input',function(){inp.value=inp.value.replace(/\D/g,'');if(inp.value&&i<ins.length-1)ins[i+1].focus();var code=[].map.call(ins,function(x){return x.value}).join('');out.textContent=code.length===4?'Code: '+code:'Waiting…'});inp.addEventListener('keydown',function(e){if(e.key==='Backspace'&&!inp.value&&i>0)ins[i-1].focus()})});
Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.