Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable tabbing to an html element? 3

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
Is there--without the use of javascript--a way to have an html <input> element ignore tabstops?

For example, I have a table with 5 columns, in these column td cells is in input textbox, and the tab key will step through columns 1 through 5, but I want it to go from 2 to 4, skipping over 3.

Without using onblur, focus, etc, how can I just make that input element ignore the tab and have it skip over?
Thanks,
--Jim
 
You can set the input to disabled, but of course that precludes any possibility of editing it.

Other than that, there is no way to do it without Javascript.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
One more thing: You could also use the tabindex property of the element and set it very high, so it becomes the last thing a user can tab into.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
set the tabindex to "-1" and it won't ever get highlighted with the tab key.

Code:
<input type="text" tabindex="-1" name="tbx" id="tbx" />

Works with all form elements, and the <a> and <area> tags as well.





--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
vicvirk
Thanks, that did the trick!
--Jim
 
Hi

Nice one, vicvirk. Strange that it works in Gecko, Presto, KHTML and WebKit, even in strict documents, although it is invalid HTML.
HTML 4.01 said:
tabindex = number [CN]
This attribute specifies the position of the current element in the tabbing order for the current document. [highlight]This value must be a number between 0 and 32767.[/highlight] User agents should ignore leading zeros.
Forms | Giving focus to an element | Tabbing navigation
W3C Markup Validation Sevice said:
Line 14, Column 30: character "-" is not allowed in the value of attribute "TABINDEX"
<input type="text" tabindex="[red]-[/red]1" name="tbx">

Feherke.
 
It works *because* it's invalid.
As the engine tries to process the "-" character it decides the attribute has an invalid value and therefore sets it to nothing.
You can get the same effect with "-0" for example.
If you want it to validate, simply put nothing for the value as in this:
Code:
<input type="text" tabindex="" name="tbx" id="tbx" />


Trojan.
 
Just a note of caution - if you're supposed to be able to enter a value into this <input> by clicking in it, you make the form inaccessible to some disabled users by disallowing tabbing.

If you're not supposed to be able to enter a value, why use an <input> in the first place?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top