I am wanting to know whether [ and ] are XHTML1-valid characters for use
within an id attribute and/or a name attribute. http://validator.w3.org/check?uri=ht...ss=1&verbose=1
(e.g. see line 77) suggests that it is valid, but the spec suggests that
it is not.
More detail:
I have a form containing a variety of input elements, including a checkbox
array.
For ease of processing the form, it would be helpful if the name of each
element in the checkbox array could include [ ] e.g.
<input type="checkbox" name="formname[checkbox][number]" />
However, looking at the HTML4 spec, which XHTML1.0Transit ional piggy-backs
onto, the specification suggests that [ and ] are not valid characters for
use within this: http://www.w3.org/TR/html401/types.html#type-name
"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 (".")."
However, a page I have online at present which uses [ ] does validate to
XHTML1.0Transit ional: http://validator.w3.org/check?uri=ht...ss=1&verbose=1
eg. line 77 contains name="main[function]"
Is [ and ] therefore valid?
Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22 www.lucas-smith.co.uk 4 21298
Martin Lucas-Smith wrote: I am wanting to know whether [ and ] are XHTML1-valid characters for use within an id attribute and/or a name attribute.
http://validator.w3.org/check?uri=ht...ss=1&verbose=1
(e.g. see line 77) suggests that it is valid, but the spec suggests that it is not.
More detail:
I have a form containing a variety of input elements, including a checkbox array.
For ease of processing the form, it would be helpful if the name of each element in the checkbox array could include [ ] e.g.
<input type="checkbox" name="formname[checkbox][number]" />
However, looking at the HTML4 spec, which XHTML1.0Transit ional piggy-backs onto, the specification suggests that [ and ] are not valid characters for use within this:
http://www.w3.org/TR/html401/types.html#type-name
"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 (".")."
However, a page I have online at present which uses [ ] does validate to XHTML1.0Transit ional:
http://validator.w3.org/check?uri=ht...ss=1&verbose=1
eg. line 77 contains name="main[function]"
Is [ and ] therefore valid?
When you look at http://www.w3.org/TR/xhtml1/dtds.htm...onal.dtd_input
you will see that the name attribute of <input> is of type CDATA
therefore for XHTML 1.0 transitional the [] in a name attribute value of
an <input> element will pass validation with an XML parser.
The id attribute is defined to be of type ID and that doesn't allow [ or ].
--
Martin Honnen http://JavaScript.FAQTs.com/
[Summary: Can anyone point me to a definitive reference of where the
allowed characters for a valid XHTML name attribute (of an input/form) tag
is, so I can make a regexp from this (or even also provide me with a
regexp!)?]
A while ago I posted to this list wanting to know whether [ and ] are
XHTML1-valid characters for use within an id attribute and/or a name
attribute. I need to apply this more generally now beyond just [].
Ultimately, I'm trying to get an regexp for validating a form API-supplied
name for both an input tag (<input name="something " ... /> and for a form
name <form name="something ">, i.e. in PHP
$formName = 'name';
$regexp = '[something]';
if (!ereg ($regexp, $formName)) {
'The form name must consist of characters....
}
I understand that in HTML4, [] and are allowed this is not the case: http://www.w3.org/TR/html401/types.html#type-name
"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 (".")."
But that in XHTML the allowed characters are different (as I have been
told they include []) :
When you look at http://www.w3.org/TR/xhtml1/dtds.htm...onal.dtd_input you will see that the name attribute of <input> is of type CDATA therefore for XHTML 1.0 transitional the [] in a name attribute value of an <input> element will pass validation with an XML parser. The id attribute is defined to be of type ID and that doesn't allow [ or ]. --
However, I can't see where exactly the CDATA type is defined for XHTML
Transitional, which is the doctype I'm using? Therefore:
** Can anyone point me to a definitive reference of where the allowed
characters for a valid XHTML name attribute (of an input/form) tag is, so
I can make a regexp from this (or even also provide me with a regexp!)? **
Martin
Martin Lucas-Smith wrote: [Summary: Can anyone point me to a definitive reference of where the allowed characters for a valid XHTML name attribute (of an input/form) tag is, so I can make a regexp from this (or even also provide me with a regexp!)?]
[snip] I understand that in HTML4, [] and are allowed this is not the case:
> http://www.w3.org/TR/html401/types.html#type-name > > "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 (".")."
[snip]
You are confusing data types with attributes. The name attribute for the
<input> element type is clearly listed as being CDATA, not ID or NAME
tokens:
<URL:http://www.w3.org/TR/html401/interact/forms.html#h-17.3>
<URL:http://www.w3.org/TR/html401/interact/forms.html#h-17.4>
The only real restriction on what characters can appear in form control
names is when a form is submitted with GET:
"The "get" method restricts form data set values to ASCII characters."
-- <URL:http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1>
However, I can't see where exactly the CDATA type is defined for XHTML Transitional, which is the doctype I'm using?
[snip]
<URL:http://www.w3.org/TR/REC-xml#attdecls>
--
Jim Dabell [Summary: Can anyone point me to a definitive reference of where the allowed characters for a valid XHTML name attribute (of an input/form) tag is, so I can make a regexp from this (or even also provide me with a regexp!)?] You are confusing data types with attributes. The name attribute for the <input> element type is clearly listed as being CDATA, not ID or NAME tokens:
I must confess I don't fully understand how the spec is read :), hence my
question.
The only real restriction on what characters can appear in form control names is when a form is submitted with GET:
"The "get" method restricts form data set values to ASCII characters."
-- <URL:http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1>
Erm, I'm strictly referring to what appears as XXX in the following:
<input name="xxx" ... />
Can anyone supply an unambiguous reference/regexp as to what xxx can be
for the page still to validate as XHTML?
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Don |
last post by:
Using PHP, I'm creating an <input> tag. How do you delimit the text string for the value parm of an
<input> tag, when the string contains the delimit char?
Example: <input...value="This text has a " in it"...>
I tried preceeding the " with a the escape char \, but the browser apparently still used the
embedded " as termination of the value string.
One other thing...is the delimiter limited to just " and ' ?
|
by: chirs |
last post by:
Hi,
I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie. How can I fix it?
<input type="text" name="box1" onblur=document.cookie="user=" +
box1.value>
Chris
|
by: Felipe Gasper |
last post by:
Does anyone have thoughts on whether the text-transform attribute of input
tags should apply to the displayed text in the browser? It's not
*enclosed*, which I think is what the CSS2 spec refers to, and KHTML
doesn't do this, but Gecko and IE both do.
An example may be found at
http://fshn3152.foods.uiuc.edu/~fgasper/test.php
If you look at this page in IE or a Gecko-based browser, the input field's
text will be in allcaps, but in...
|
by: TR |
last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox
with a nested label?
This is the label of the
checkbox that wraps beneath it
I'd prefer it looked like this, with a flush left margin:
|
by: Ben |
last post by:
Here's my form:
<form name="aForm" method='post'>
<input type=file name=file1 onkeypress='KeyPress()'><br>
<a
id='attachMoreLink'
href='javascript:AddFileInput()">Attach More Files
</a>
<input type=submit value='Done'>
</form>
| |
by: Bart van Deenen |
last post by:
Hi all
I have a form with a couple of input fields, embedded within spans. I am
using script.aculo.us for dragging and dropping, and want to reorder the
input fields that way. The input fields are display:inline because I
want them all on the same line.
Does anyone know of a smart trick to be able to drag these input fields?
Just setting their disabled attribute doesn't work, because then they
get no events. Not setting disabled just...
|
by: Richard Maher |
last post by:
Hi,
I'm trying to use the Visibility Style attribute for a Div to effectively
PopUp a lightweight window with some additional context-sensitive
information, when a user mouses over a given field(s). The popping-up seems
to work just fine; it's the tearing down that's giving me grief. If I stick
a onmouseout event on the same input field that caused the
onmouseover/pop-up, it starts to flicker 'cos the <divis placed for
esthetically...
|
by: jodleren |
last post by:
Hi
I tried getElementById, it works in IE, but how I find items on a form
properly?
I can write a small for myself, but is there a function to find
<inputitems on a form?
That is, standard JS which also works in Mozilla
WBR
Sonnich
|
by: =?Utf-8?B?U3VtaXQgUmF3YXQgSW5kaWE=?= |
last post by:
What I have seen in Asp.net applications that if i put two Asp buttons on the
web form(Aspx page)
it generates multiple name attribute of input tag on the client side.
for eg.
<asp:Button ID="btn" value="first" runat="server" name="btnname"/>
<asp:Button ID="Button1" value="second" runat="server" name="btnname"/>
After the execution it shows the result in following way:--
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |