[thelist] javascript and form fields with numeric ID/name

Andrew Clover and-evolt at doxdesk.com
Sat Dec 4 17:47:28 CST 2004


Christian Heilmann <lists at onlinetools.org> 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 (".").

Just to clear up a point of confusion that always arises when this comes 
up: the attribute 'name' on HTML form fields (<input>, <select>, 
<textarea> and <button>) is *not* defined as taking NAME content. It's 
CDATA, which means you can stick what you like in it, including numbers 
at the start.

The only time a 'name' attribute is actually of content type NAME (in 
SGML or XML terms) is in the little-used <meta name="xyz">.

IDs are more limited, but IDs are not needed for form fields anyway, 
unless you're using the DOM Level 1 method getElementById. In this case 
the name and id attributes can contain completely different values 
without problem.

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/


More information about the thelist mailing list