JSFiddle - React, Tailwind, and code Playground

by jquerybyexample

HTML

First Name : <input type='text' id='txtFirstName' /> <br/><br/>
Last Name : <input type='text' id='txtLastName' /><br/><br/>
Age : <input type='text' id='txtAge' /><br/><br/>

<input type='button' id='btnSubmit' Value =' Submit'/>

JavaScript

$(document).ready(function() {
$('input:text:first').focus();
    
$('input:text').bind("keydown", function(e) {
   var n = $("input:text").length;
   if (e.which == 13) 
   { //Enter key
     e.preventDefault(); //to skip default behavior of the enter key
     var nextIndex = $('input:text').index(this) + 1;
     if(nextIndex < n)
       $('input:text')[nextIndex].focus();
     else
     {
       $('input:text')[nextIndex-1].blur();
       $('#btnSubmit').click();
     }
   }
});

$('#btnSubmit').click(function() {
    alert('Form Submitted');
});
});