title: Place Cursor on Input Number box when tab is pressed
body: <p>I have the below HTML input type Number</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type=“number” class=“reqField” id=“number1” placeholder=“Enter Number only/&gt;
  &lt;input type=“number” class=“reqField” id=“number2” placeholder=“Enter Number only/&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function focusInNumber (id) {
  var thisID = id;
  var nextID = id + 1;
  var preID = id - 1;
  clearTimeout(numberReturn);
  $(“#number” + thisID).prop(“disabled”, false);
  placeCursor($(“#number” + thisID));
  }
  function focusOutNumber (id) {
  var thisID = id;
  var nextID = id + 1;
  var preID = id - 1;
  var value = $(“#number” + thisID).val();
  var regex = new RegExp(/^\d*$/);
  var regex1 = new RegExp(/^.*[\+\-\.].*/);
  var l = $(“#number” + thisID).val().length;
  if(value.match(regex3)) {
  alert(“Just enter numerical digits”);
  numberReturn = setTimeout(function() {
  placeCursor($(“#number” + thisID));
  },5000);
  } else {
  if (l&lt;=0) {
  alert(“This field cannot be empty”);
  placeCursor($(“#number” + thisID));
  },5000);
  } else {
  if(value.match(regex)) {
  placeCursor($(“#number” + nextID));
  }
  }
  }
  function placeCursor(id) {
  id.focus();
  //id.val(id.val());
  var tmp= id.val();
  id.val(“”);
  id.va(tmp);
  //id.focus().val(“”).blur().focus().val(tmp);
  }
  
  $(document).ready(function(){
  ....
  $(“#number1”).focusin(function(){
  focusInNumber(1);
  });
  $(“#number1”).focusout(function(){
  focusOutNumber(1);
  });
  ...
  });
  </code></pre>
  
  <p>So the problem is that every time tab is pressed, the next text box is focused but the cursor is not in it. 
  I have to click on it to type.
  I can’t figure out why it’s behaving like this on chrome and IE.</p>
  
  <p>As chrome selection is only permitted with type text/search, url, tel, and password and not on type Number, <code>selectionStart</code> and <code>selectionEnd</code> is out of option.
  I cannot change the type of the text box to text from number too.</p>
  
  <p>Every commented code on <code>placeCursor</code>function are tried options with no luck on fixing the issue.</p>
  
  <p>Please help place cursor on the text box when tab is pressed from text box <code>Number1</code> to <code>Number2</code> once it just has numerical digits.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Getting </p>
  
  <blockquote>
    <p>Uncaught RangeError: Maximum call stack size exceeded</p>
  </blockquote>
  
  <p>On every .focus(). This is the problem which keeps the cursor not on the focused input text box. Try-Catch ignores the error, but does not places the cursor on the input textbox.Can someone help fix it?</p>