Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

w3c document.forms[0].fieldname equivalent

I've been using

document.forms[0].fieldname.value

to get values in javascript from a form, but I'd like to use a name to reference the field and not a 0, what would be the equivalent these days since <form name="formname"> isn't compliant?

like image 528
Amien Avatar asked Mar 05 '26 19:03

Amien


1 Answers

The forms collection is standard DOM 1, there is nothing wrong with using it.

document.forms.formId.elements.field
like image 134
Quentin Avatar answered Mar 08 '26 08:03

Quentin