Forum Moderators: open
why can't i use a [] in a id attribute.
example:
<input type="text" id="myform[Text1]" name="myform[Text1]" /> The W3C Validator says that the [ char can't be used.But why?
It is very handy in PHP to let it return an array in the POST or GET Arguments.
If anyone has a reason or something or can explain this to me.
Or should i just use it and ignore this warning/error?
Thx in advanced.
However, in XHTML1.0 it was changed to NMTOKEN, a type which *can't* have square brackets in.
There's no rule that says your ID and Name have to be the same, so in HTML4 you can quite happily go with something like:
<select multiple id="myname" name="myname[]">
I think I'm right in saying that a similar naming convention with an XHTML1.0 DOCTYPE doesn't trip the W3C's validator, even though it's technically incorrect.