<form>
<input tabindex="1" required>
<input tabindex="2" required>
<input>
<input tabindex="3" required>
<input>
<input tabindex="4" required>
<input tabindex="5" required>
<button type="button" tabindex="6"></button>
<button type="submit" tabindex="7"></button>
</form>
Here I have a form with some input fields and two button at the end of the form… and I am using tabindex attribute to focus them in order… now on tab key down I need to focus the first input field with tabindex="1" after release focus from the submit button as like as the form focus input field of tabindex="3" after releasing focus from input field of tabindex="2"… How can I do that…??
please don’t use any jQuery… only javascript or html…
Finally, I have solved my problem… with HTML and a little javascript it can be done easily… means loop focus of input fields inside a form…
Here I skip the
tabindex="1"and start withtabindex="2"… then I add 2 moreattributein thesubmitbutton…onFocus&onBlur… moreover, I am using theidattribute to memory the primary or real tabindex number of the submit button… when the user will focus on the submit button, javascript will change itstabindexfrom8to1… now if the user hit the tab button the form will try to find out the element that have the nexttabindex… means the first input field… again, when the focus will leave the submit button, javascript will retrieve its realtabindexfrom itsid… means thetabindexwill be changed from1to8… in this way the focus will keep looping inside the form…Live Demo