Javascript Form Object
The Form object represents an HTML form. For each instance of an HTML <form> tag in a document, a Form object is created.
Forms are used to prompt users for input. The input data is normally posted to a server for processing.
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Form Object Collections
Collection |
Description |
IE |
F |
N |
W3C |
elements[] |
Returns an array containing each element in the form |
3 |
1 |
2 |
Yes |
Form Object Properties
Property |
Description |
IE |
F |
N |
W3C |
acceptCharset |
Sets or returns a list of character encodings for form data that must be accepted by the server processing the form |
3 |
|
|
Yes |
action |
Sets or returns the URL of where the input data will be submitted |
3 |
1 |
2 |
Yes |
encoding |
Sets or returns the MIME encoding for the form |
3 |
1 |
2 |
No |
enctype |
Sets or returns the MIME encoding for the form |
5 |
1 |
6 |
Yes |
id |
Sets or returns the id of the form (In IE 4 this property is read-only) |
4 |
1 |
|
No |
length |
Returns the number of elements in a form |
3 |
1 |
2 |
Yes |
method |
Sets or returns how form data is submitted to the server ("get" or "post") |
3 |
1 |
2 |
Yes |
name |
Sets or returns the name of the form |
3 |
1 |
2 |
Yes |
tabIndex |
Sets or returns the index that defines the tab order for the form |
5 |
|
|
No |
target |
Sets or returns the target window or frame that responses are sent to after submission of a form |
3 |
1 |
2 |
Yes |
Form Object Methods
Method |
Description |
IE |
F |
N |
W3C |
reset() |
Resets the default values of all elements in the form (same as clicking the Reset button) |
4 |
1 |
3 |
Yes |
submit() |
Submits the form (same as clicking the Submit button) |
3 |
1 |
2 |
Yes |
Form Object Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
IE |
F |
N |
W3C |
onReset |
Executes some code when a Reset event occurs |
4 |
1 |
3 |
|
onSubmit |
Executes some code when a Submit event occurs |
3 |
1 |
2 |
|
|