Subject: | Tabindex starts at 0 instead of 1 if start_html is not used |
Using CGI.pm 3.0.7 on Linux (Red Hat 9, kernel 2.4.29) with Perl 5.8.0
If CGI.pm methods are used to generate form fields, but not the entire HTML document -- specifically, if start_html is not used -- tabindex numbering starts at 0 instead of 1. Since a tabindex of 0 is equivalent to not having a tabindex property at all, this can result in an unexpected tab order. (With the tabindex=0 field selected, tabbing will jump to the next tab *without* a tabindex instead of jumping to tabindex=1.)
Noticed on OpenWebmail, which uses CGI.pm to fill in fields in pre-defined templates.
Test case:
#!/usr/bin/perl
use CGI qw(:standard);
print "Content-type: text/html\n\n";
# Swap the next two lines and look at the tabindexes generated.
#print start_html(-title=>'Tabindex Test');
print "<html><head><title>Tabindex Test</title></head><body>";
print startform(-action=>"doesntmatter.pl");
print p ('Login', textfield(-name=>'loginname', -size=>10) );
print p ('Password', password_field(-name=>'password', -size=>10) );
print submit(-value=>'Submit this' );
print end_form();
print qq~<p><a href="/">No tabindex</a> - <a href="/">here either</a></p>~;
print end_html();