Form : Form Object « Form « JavaScript Tutorial






The Form object represents an HTML property created by the
tag.

The Form object can be used to access all the properties of the specified form.

Forms can be referenced by either the forms array or directly by name.

Form methods and properties.

Property/MethodDescription
actionHTML ACTION attribute of Form object
elementsArray reflecting elements within form
elements.lengthLength of elements array
encodingHTML ENCTYPE attribute of Form object
handleEvent()Handles specific event
lengthNumber of elements within form
methodHTML METHOD attribute of Form object
nameHTML NAME attribute of Form object
onResetEvent handler for Reset button
onSubmitEvent handler for Submit button
reset()Resets form elements
submit()Submit for data
targetHTML TARGET attribute of Form object


<html>
    <head>
    <title> Using the name property to access a form object</title>
    </head>
    <body>
    <script language = "JavaScript">
    <!--
    function checkName(){
         var firstName = document.formEx.first.value;
         var lastName = document.formEx.last.value;
         alert("The name you entered is: " + firstName + " " + lastName);
    }
    -->
    </script>
    <form name="formEx">
    First Name:
    <input type="text" name="first" size="20">
    Last Name:
    <input type="text" name="last" size="25">
    <br><br>
    Click the button to check that the information is correct.
    <br>
    <input type="button" value="verify" name="check" onClick='checkName()'>
    </form>
    </body>
    </html>








10.2.Form Object
10.2.1.Form
10.2.2.Using the Forms Array
10.2.3.Form.action
10.2.4.Form.elements
10.2.5.Form.elements.length
10.2.6.form.encoding
10.2.7.Form.handleEvent()
10.2.8.Form.length
10.2.9.Form.method
10.2.10.Form.name
10.2.11.Form.onReset
10.2.12.Form.onSubmit
10.2.13.Form.reset()
10.2.14.Form.submit()
10.2.15.Form.target