Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1145 Is there any way of validating a form on a page without using the name attribute in the form tag?

You are here: irt.org | FAQ | JavaScript | Form | 5 | Q1145 [ previous next ]

You can access forms using their position within the document forms array using their index:

document.forms[0]; // - first form in page
document.forms[1]; // - second form in page
document.forms[document.forms.length-1]; // - last form in page 

From a form field (but not the form tag itself) you can also use this.form to refer to the specific form object:

<input type="button" onClick="functionName(this.form)">

©2018 Martin Webb