473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

naming syntax rules

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
Jun 27 '08 #1
8 1006
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
Jun 27 '08 #2
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).
Jun 27 '08 #3
On 23 Apr, 14:12, Bart Van der Donck <b...@nijlen.comwrote:
| 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 []
Jun 27 '08 #4
On Wed, 23 Apr 2008 16:24:36 +0200, Captain Paralytic
<pa**********@yahoo.comwrote:
On 23 Apr, 14:12, Bart Van der Donck <b...@nijlen.comwrote:
> | 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
Jun 27 '08 #5
Henry wrote:
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).
Oddly, in practice, it works the other way. All browsers I tested
recognized the number first for IDs, IE failed for number first for form
element name. Of course, IE's quirks are legion.

With that said, I'll rewrite my IDs for this particular app to conform.

Jeff
Jun 27 '08 #6
Henry wrote:
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.
Full ACK.
('2-some_name' may not be a viable ID but it is a valid NAME).
^^^^
I think you meant `name' in the sense of "value of the `name' attribute of
`form' elements or form controls" here, for the above definition makes it
very clear that ID and NAME tokens have the same restrictions.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #7
Captain Paralytic wrote:
On 23 Apr, 14:12, Bart Van der Donck <b...@nijlen.comwrote:
> | 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 []
It does not need to. Apparently you haven't been paying attention.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #8
Rik Wasmus wrote:
[...] Captain Paralytic [...] wrote:
>On 23 Apr, 14:12, Bart Van der Donck <b...@nijlen.comwrote:
>> | 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 :)
[...]
Not in *all* `name' attribute *values*, but in most, including those
relevant here.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
7
by: DEX | last post by:
Main page of my NC: http://www.ddmrm.com/coding/cpp/naming/cpp.naming.main.html Rules of my NC: http://www.ddmrm.com/coding/cpp/naming/cpp.naming.rules.html Comments are welcome. ...
0
by: Carl Colijn | last post by:
Hi all, Disclaimer: before I might trigger your "let's start a holy war!" button, I'd like to say I'm not intended to; I just post this message to get some input and not to promote "Yet Another...
8
by: bim_bom | last post by:
Hi, is there any tool to change naming convention in c++ sources? I mean something, that parses cpp and h files in my project, and it finds, what variables are there declared. I think, it should...
17
by: Miguel Guedes | last post by:
Hello, Does anyone have a link to the C++ Standard Library naming conventions that they could share? I have found a few links to pages on C++ naming conventions but am unsure as to what standard...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.