Member Avatar for mehnihma
mehnihma

Hi
I found this code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function enterAsTab() {
  var keyPressed = event.keyCode; // get the Key that is pressed
  if (keyPressed == 13)
  { 
    //case the KeyPressed is the [Enter]
    var inputs = $('input'); // storage a array of Inputs
    var a = inputs.index(document.activeElement); 
    //get the Index of Active Element Input inside the Inputs(array)

    if (inputs[a + 1] !== null)
    {
      // case the next index of array is not null
      var nextBox = inputs[a + 1]; 
      nextBox.focus(); // Focus the next input element. Make him an Active Element
      event.preventDefault();
    }

    return false;
  } 

  else {return keyPressed;}
}
</script>

It works but on some fileds, like on chekboxes it does not, tab normaly works.

Do you know maybe how to adopt this script to make it work on all fileds?

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.