469,310 Members | 2,610 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,310 developers. It's quick & easy.

Name of Form Element begin with number

I have problem in retrieve a value of a form element that have name
begin with a number. For example, for this HTML code
<input type="text" name="0000ABC12345CD6789" id="0000ABC12345CD6789">
I got Javascript error at document.form.0000ABC12345CD6789.value

Thanks.
Jul 20 '05 #1
2 1585
In article <91************************@posting.google.com>,
vi****@juno.com enlightened us with...
I have problem in retrieve a value of a form element that have name
begin with a number. For example, for this HTML code
<input type="text" name="0000ABC12345CD6789" id="0000ABC12345CD6789">
I got Javascript error at document.form.0000ABC12345CD6789.value

Thanks.


Don't use the shortcut syntax if your elements begin with numbers or
special characters. It's not very cross-browser, anyway.

And I sure hope you didn't name your form "form"...

Sub your formname here.
document.forms["formname"].elements["0000ABC12345CD6789"].value

--
--
~kaeli~
A man needs a mistress... just to break the monogamy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
Hi,

Viet wrote:
I have problem in retrieve a value of a form element that have name
begin with a number. For example, for this HTML code
<input type="text" name="0000ABC12345CD6789" id="0000ABC12345CD6789">
I got Javascript error at document.form.0000ABC12345CD6789.value

Thanks.


This is not legal HTML.

From the HTML 4.01 specs:
<quote>
# 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 (".").
</quote>

See the specs at
<URL: http://www.w3.org/TR/html401/types.html#type-cdata>

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jochen Daum | last post: by
12 posts views Thread by CJ | last post: by
4 posts views Thread by Martin Lucas-Smith | last post: by
6 posts views Thread by Neil Cherry | last post: by
24 posts views Thread by Chameleon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.