[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