Reputation: 111
My question is : Can I give same name and id to an element in html text-field form?
I can retrieve the values entered by user from the name identifier also, but as I have to use them in my functions in an external java script file, will giving both id and name identifiers be better and can both be given same identifier ?
Thanks,
Upvotes: 3
Views: 3432
Reputation: 75629
Yes, you can give the same name and id to your form element. This is fine to have:
<input name="foo" id="foo" ... />
Upvotes: 4