<p>I have a form like this:</p>

<pre><code>&lt;form name="mine"&gt;
    &lt;input type=text name=one&gt;
    &lt;input type=text name=two&gt;
    &lt;input type=text name=three&gt;
&lt;/form&gt;
</code></pre>

<p>When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. For example, if user types '123' and uses Tab to move to next field, I want to skip it and go to field three.</p>

<p>I tried to use <code>OnBlur</code> and <code>OnEnter</code>, without success. </p>

<p><strong>Try 1:</strong></p>

<pre><code>&lt;form name="mine"&gt;
    &lt;input type=text name=one onBlur="if (document.mine.one.value='123') document.three.focus();&gt;
    &lt;input type=text name=two&gt;
    &lt;input type=text name=three&gt;
&lt;/form&gt;
</code></pre>

<p><strong>Try 2:</strong></p>

<pre><code>&lt;form name="mine"&gt;
    &lt;input type=text name=one&gt;
    &lt;input type=text name=two onEnter="if (document.mine.one.value='123') document.three.focus();&gt;
    &lt;input type=text name=three&gt;
&lt;/form&gt;
</code></pre>

<p>but none of these works. Looks like the browser doesn't allow you to mess with focus while the focus is changing. </p>

<p>BTW, all this tried with Firefox on Linux.</p>

[{'answer_id': 79317, 'author': 'dimarzionist', 'author_id': 10778, 'author_profile': 'https://Stackoverflow.com/users/10778', 'pm_score': 3, 'selected': True, 'text': '<p>Try to attach tabindex attribute to your elements and then programmaticaly (in javaScript change it):</p>\n\n<pre><code>&lt;INPUT tabindex="3" type="submit" name="mySubmit"&gt;\n</code></pre>\n'}, {'answer_id': 79323, 'author': '17 of 26', 'author_id': 2284, 'author_profile': 'https://Stackoverflow.com/users/2284', 'pm_score': 1, 'selected': False, 'text': '<p>You could use the <a href="http://www.w3schools.com/jsref/jsref_onfocus.asp" rel="nofollow noreferrer">onfocus</a> event on field two, which will be called when it receives focus.  At that point, field 1\'s value should be updated and you can perform your check then.</p>\n'}, {'answer_id': 79335, 'author': 'Thomas', 'author_id': 14637, 'author_profile': 'https://Stackoverflow.com/users/14637', 'pm_score': 1, 'selected': False, 'text': "<p>If you used the method you describe, and they worked, the focus would also change when the user clicks on the field, instead of tabbing to it. I can guarantee you that this would result in a frustrated user. (Why exactly it doesn't work is beyond me.)</p>\n\n<p>Instead, as said before, change the tabindex of the appropriate fields as soon as the content of field one changes.</p>\n"}, {'answer_id': 79345, 'author': 'John Boker', 'author_id': 2847, 'author_profile': 'https://Stackoverflow.com/users/2847', 'pm_score': 0, 'selected': False, 'text': '<pre><code>&lt;form name="mine"&gt;\n    &lt;input type="text" name="one" onkeypress="if (mine.one.value == \'123\') mine.three.focus();" /&gt;\n    &lt;input type="text" name="two"&gt;\n    &lt;input type="text" name="three"&gt;\n&lt;/form&gt;\n</code></pre>\n'}, {'answer_id': 79347, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Try <code>onkeypress</code> instead of <code>onblur</code>. Also, on the <code>onfocus</code> of field two is where you should be sending to three. I'm assuming you don't want them typing in two if one is 123 so you can just check that on two's <code>onfocus</code> and send on to three.</p>\n"}]
['https://Stackoverflow.com/questions/79275', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14690/']