JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" max="12" class="form-control" id="cmzTextLines1" name="cmzTextLines1">
<input type="text" max="12" class="form-control" id="cmzTextLines2" name="cmzTextLines2">
<input type="text" max="12" class="form-control" id="cmzTextLines2" name="cmzTextLines3">
<input type="text" class="form-control" id="cmzTextLines2" name="cmzTextLines4">

JavaScript

$(".form-control").on("keydown", function(e) {
  var max = $(this).attr("max");
  var length = $(this).val().length;
  var key = String.fromCharCode(e.which);

  if (length >= max && e.keyCode != 8) {
    if (key != " ") {
    	var rawval = $(this).val();
    	var fieldval = rawval.split(/[ ,]+/);
      var lastword = fieldval[fieldval.length - 1];
      var lastwordlength = lastword.length;
      
      var replacedval = rawval.substring(0, rawval.length - lastwordlength);
      
      $(this).val(replacedval);
      $(this).next(".form-control").val(lastword);
    }
    
    $(this).next(".form-control").focus();
  }
})