[Chapter 21] Reference: Checkbox.defaultChecked
Author: David Flanagan
Date: Fri Aug 29 11:14:17 1997

#

| Chapter 21 JavaScript Reference |

# Checkbox.defaultChecked Property

## Name

Checkbox.defaultChecked Property---initial state of a Checkbox

## Availability

Navigator 2.0, Internet Explorer 3.0

## Synopsis

    checkbox.defaultChecked

## Description

`defaultChecked` is a read-only Boolean property of the Checkbox object. It is `true` if the Checkbox is initially checked--i.e., if the `CHECKED` attribute appears in the Checkbox's HTML `<INPUT>` tag. If this tag does not appear, then the Checkbox is initially unchecked, and `defaultChecked` is `false`.

## Usage

You can use the `defaultChecked` property to reset a Checkbox back to its default state. You might do this when the user selects a Reset button in a form, for example. You can reset a Checkbox with the following function:

    function resetCheckbox(checkbox) {
        if (checkbox.defaultChecked) checkbox.checked = true;
        else checkbox.checked = false;
    }

## See Also

"Checkbox"

Checkbox.click() |  | Checkbox.focus()