From: Jeff on
I've just run into a weird quirk in IE where I had named form
elements like this: 2-some_name. IE was using just the numeric part as
an index in the form collection array. Boy, that took a while to figure out!

So, what are the rules for names and ids? I had thought this was
loosened up years ago.

Jeff
From: Bart Van der Donck on
Jeff wrote:

>    I've just run into a weird quirk in IE where I had named form
> elements like this: 2-some_name. IE was using just the numeric part as
> an index in the form collection array. Boy, that took a while to figure
> out!
>
>    So, what are the rules for names and ids? I had thought this was
> loosened up years ago.

| ID and NAME tokens must begin with a letter ([A-Za-z]) and may
| be followed by any number of letters, digits ([0-9]), hyphens
| ("-"), underscores ("_"), colons (":"), and periods (".").

http://www.w3.org/TR/REC-html40/types.html

--
Bart
From: Henry on
On Apr 23, 3:12 pm, Bart Van der Donck wrote:
> Jeff wrote:
>> I've just run into a weird quirk in IE where I had named
>> form elements like this: 2-some_name. IE was using just the
>> numeric part as an index in the form collection array. Boy,
>> that took a while to figure out!
>
>> So, what are the rules for names and ids? I had thought
>> this was loosened up years ago.
>
> | ID and NAME tokens must begin with a letter ([A-Za-z]) and may
> | be followed by any number of letters, digits ([0-9]), hyphens
> | ("-"), underscores ("_"), colons (":"), and periods (".").
>
> http://www.w3.org/TR/REC-html40/types.html

This is relevant for ID attributes, but NAME attributes are CDATA
(except for the NAME attributes of META elements, which are NAME
tokens) and so the preceding section of - REC-html40/types.html -
defines their restrictions. ('2-some_name' may not be a viable ID but
it is a valid NAME).
From: Captain Paralytic on
On 23 Apr, 14:12, Bart Van der Donck <b...(a)nijlen.com> wrote:
> | ID and NAME tokens must begin with a letter ([A-Za-z]) and may
> | be followed by any number of letters, digits ([0-9]), hyphens
> | ("-"), underscores ("_"), colons (":"), and periods (".").


Interesting that it doesn't allow []
From: Rik Wasmus on
On Wed, 23 Apr 2008 16:24:36 +0200, Captain Paralytic
<paul_lautman(a)yahoo.com> wrote:

> On 23 Apr, 14:12, Bart Van der Donck <b...(a)nijlen.com> wrote:
>> | ID and NAME tokens must begin with a letter ([A-Za-z]) and may
>> | be followed by any number of letters, digits ([0-9]), hyphens
>> | ("-"), underscores ("_"), colons (":"), and periods (".").
>
>
> Interesting that it doesn't allow []

Not in ID's, but for PHP luckily in name attributes it's allowed :)
From http://www.w3.org/TR/html4/strict.dtd:

.....
<!ELEMENT INPUT - O EMPTY -- form control -->
<!ATTLIST INPUT
%attrs; -- %coreattrs, %i18n, %events --
type %InputType; TEXT -- what kind of widget is needed --
name CDATA #IMPLIED -- submit as part of form --
.....

So, just CDATA in name attributes.
--
Rik Wasmus