you just need to use keyup
event instead of change
and other logic will work as is
$(function(){
$("#input1").on('keyup', function() {
if ($(this).val().length == 4) {
$("#input2").focus();
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<input type="text" id="input1">
<input type="text" id="input2">
CLICK HERE to find out more related problems solutions.