Javascript - Working with Form and Form Fields

javascript-dom

form.action
form.method
form.encoding
form.name
form.target
form.reset()
form.submit()
form.elements
form.length // provide access to the length of the elements array

element.value
document.forms[0].birthdate.value

document.form[0].submit();
var name = document.myform.name.value;  
var password = document.myform.password.value; 
document.getElementById(‘checkbox1’).checked // determine if the check box is checked

How to access the value of a form field?

element.value
document.forms[0].birthdate.value

The form object:

action    // access the HTML action attribute
button
checkbox
elements
encoding
FileUpload
hidden
length    // provide access to the length of the elements array
method    // access the HTML method attribute
name        // identifies the name of the form
password
radio
reset()    // reset the form
select
submit()    // submit the form
target    // access the HTML target attribute
text
textarea

The properties of form elements:

button    name        
        type        
        value        

checkbox    checked
        defaultChecked
        name
        type
        value
FileUpload    name
        type
        value
hidden    name
        type
        value
password    defaultValue
        name
        type
        value
radio        checked
        defaultChecked
        name
        type
        value
reset        name
        type
        value
select    length
        name
        options
        selectedIndex    // identifies the first selected option within select list
        type
submit    name
        type
        value
text        defaultValue
        name
        type
        value
textarea    defaultValue
        name
        type
        value

Methods of form elements:

button    click(), blur(), focus()
checkbox    click(), blur(), focus()
FileUpload    blur(), focus(), select() // select an input area of the file upload field
hidden
password    blur(), focus(), select() // highlight the text displayed in the password field
radio        click(), blur(), focus()
reset        click(), blur(), focus()
select    blur(), focus()
submit    click(), blur(), focus()
text        blur(), focus(), select()
textarea    blur(), focus(), select()
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License