This is an old doubt of mine which surfaced again today.
Coming from an ASP.NET background I was surprised to see this snippet<input name='text[en]' value='aaaaaa' 开发者_开发问答/>
It was the first time I am seeing an array like value given for name
My doubts are,
- Is this markup valid?
- What all values are supported for
name
? - Where can I see a W3C specification on this?
this html is not valid
please refer to w3c html spec below:
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 (".").
src: section 6.2 of http://www.w3.org/TR/html401/types.html
"[" and "]" are not allowed in value of "NAME" attribute.
and, asp.net doesn't support this, though some php code can do this.
1 - Yes, it's possible.
2 - Name is type CDATA:
CDATA
Attribute values of type CDATA are made up of a sequence of characters that may include entities. Line feeds are ignored while each carriage return and tab is replaced with a space. Browsers may ignore leading and trailing whitespace within the attribute value.
CDATA attribute values are typically case-sensitive, though this is not the case with all attributes that take CDATA values.
3 - Maybe this help: http://www.w3.org/TR/html4/interact/forms.html#h-17.4
Yes is the answer but it's only the string.
You can use <input name="test[]" />
and you will receive an array of all inputs with name "test[]" in an array with name "test"
You can read for all this in here
精彩评论