Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can HTMLInput name take the values like arrays

Tags:

html

input

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
I know that this code runs.

My doubts are,

  1. Is this markup valid?
  2. What all values are supported for name?
  3. Where can I see a W3C specification on this?
like image 233
naveen Avatar asked Jan 19 '26 20:01

naveen


1 Answers

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.

like image 93
gekowa Avatar answered Jan 21 '26 12:01

gekowa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!