JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" name="pin1" class="pin" maxlength='4'>
<input type="text" name="pin2" class="pin" maxlength='4'>
<input type="text" name="pin3" class="pin" maxlength='4'>
<input type="text" name="pin4" class="pin" maxlength='4'>
JavaScript
$('.pin').keyup(function(){
var pinLen = $(this).val().length;
if(pinLen>=4){
$(this).next().focus();
}
});