asp.net.ph

Skip Navigation Links

FORM Element | FORM Object

Language References


Creates an HTML form.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

Remarks

The FORM element acts as a container for user input controls. It specifies:

  • The layout of the form, given by the contents of the element.
  • The method by which user data will be sent to the server.
  • The program that will handle the submitted form.
  • A character encoding that must be accepted by the server in order to handle this form. Browsers may advise the user of the accepted character set and/or restrict the user's ability to enter unrecognized characters.

Forms enable client-side users to submit data to a server in a standardized format. Forms can collect data in different ways, using a variety of control elements. Users typically fill in the required data by typing directly into INPUT boxes, by checking options in a radio button or checkbox group, or by selecting options from a dropdown listbox. A submit button is ususally provided to collect and send the form's data to the server.

To be submitted with the form's data set, each of the form controls must be assigned a name and have a valid value. Only controls with a valid name/value pair are sent to the receiving program for processing.

In addition to form controls, a form can contain other elements such as tables, paragraphs, or lists.

Form Control Behavior

When the focus is on a control in a form, pressing ESC once causes the value of the control to revert back to the last value, and pressing the key again resets the form. If the focus is on the form but not on a particular control, pressing ESC once resets the form.

If the form has only one text box, pressing ENTER automatically fires the onsubmit event. If the form has a submit button, the button has a dark border, indicating that pressing ENTER submits the form.

Members

FORM Members

Example

The following sample presents a basic form containing a text entry box for searching a keyword. When the submit button is pressed, the form will send the form data to the URL listed in the action property. The value of the method property determines how the data is sent to the server.

Enter keyword:
<form action="..." method="get">
   Enter keyword: <input name="search">
      <input type=submit value="Search"
         onclick="alert ( 'This is just an example, 
            nothing will happen' );return false">
</form>
Notes on DOM Access

A form may be accessed in the following, essentially equivalent, ways:

document.formName
document['formName']
document.forms[formIndex]

An element in a form may be referenced by either its name or id properties.

document.formName.elementName
document['formName'].elementName
document.forms[formIndex].elementName

Or it may also be referenced through the elements collection.

document.formName.elements[controlIndex]
document['formName'].elements[controlIndex]
document.forms[formIndex].elements[controlIndex]
See Also

forms, Form Submission



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note