JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JSFIDDLE</title>
</head>
<body>
  <fieldset id ="test">
    <input type="text" id="1" maxlength="5" size="5"/>
    <input type="text" id="2" maxlength="5" size="5"/>
    <input type="text" id="3" maxlength="5" size="5"/>
    <input type="text" id="4" maxlength="5" size="5"/>
    <input type="text" id="5" maxlength="5" size="5"/>
  </fieldset>
</body>
</html>

JavaScript

$(document).ready(function() {
    
    $("#test input[type=text]").keydown(function(e){
      if(e.which == 8){
        if($(this).val().length == 0){
          $(this).prev().focus().val($(this).prev().val());
        }
      }
    });

    $("#test input[type=text]").keyup(function(e){
      if($(this).val().length == $(this).attr('maxlength') ){
        if($(this).parent().children().last().attr('id') == $(this).attr("id")){
          $(this).parent().next().find(':input').focus();
        }else{
          $(this).next("input").focus();
        }
      }
    });

  });