title: Switch between two textareas only when pressing Tab button
body: <p>Normally when a user is visiting a web page and pressing TAB button on a keyboard, the selection moves from one element to another starting from the begining of the page.  </p>
  
  <p>I am looking for a solution to switch between two particular text areas by pressing TAB button on a keyboard with an initial focus on the first one when web page is loaded? All other elements on the page have to be ignored for this TAB key press event.</p>
  
  <p>How can I achive this?</p>
  
  <p>Thanx for your help!</p>
  
  <p>= Update =</p>
  
  <p>I have managed to make it work under Firefox 12.0 . IE and Chrome do not work properly. Asuming the text area IDs are #ICCID and #MSISDN, the Jquery looks like this:</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(function() {
              $(document).ready(function() {
              $("#ICCID").focus();
              });
  
              var $inp = $('.cls');
  
              $inp.bind('keydown', function(e) {
                  var key = e.which;
                  if (key == 9) {
  
                      e.preventDefault();
                      var nxtIdx = $inp.index(this) + 1;                  
                      $(".cls:eq(" + nxtIdx + ")").focus();
  
                  //Simulate Enter after TAB
                  var textInput = $("#MSISDN").val();
                  var lines = textInput .split(/\r|\r\n|\n/);
                  if (lines &gt; 1) {
  
                      $("#MSISDN").on("keypress", function(e) {
                      if (e.keyCode == 9) {
                      var input = $(this);
                      var inputVal = input.val();
                      setTimeout(function() {
                      input.val(inputVal.substring(0,inputVal.length) + "\n");
                            }, 1);
                         }
                      });
                  }
  
  
  
                  }
                  if (key == 9) {
  
                      e.preventDefault();
                      var nxtIdx = $inp.index(this) - 1;
                      $(".cls:eq(" + nxtIdx + ")").focus();
  
                  //Simulate Enter after TAB
                  $("#ICCID").on("keypress", function(e) {
                  if (e.keyCode == 9) {
                  var input = $(this);
                  var inputVal = input.val();
                  setTimeout(function() {
                  input.val(inputVal.substring(0,inputVal.length) + "\n");
                        }, 1);
                     }
                  });
  
  
                  }
              });
          });
  &lt;/script&gt;
  </code></pre>