You are here: Reference > JavaScript > client-side > HTML DOM > properties > indeterminate (input:checkbox)

indeterminate property (input:checkbox)

Browser support:
3.6
Specifies or returns a Boolean value that indicates whether the state of a checkbox has changed.
Note: The indeterminate property is supported in Firefox from version 3.6.
When the indeterminate state is used for a checkbox, it behaves as a three-state control. A checkbox cannot be changed to indeterminate state through the user interface, this state can only be set from scripts. This state can be used to force the user to check or uncheck a checkbox. See the example below for details.
Note that modifying the value of the indeterminate property has no effect on the value of the checked and status properties.

Syntax:

object.indeterminate;
You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

Boolean that indicates the checkbox state.
One of the following values:
false
The checked and status properties can be used to get the current state of the checkbox.
true
The checkBox is in indeterminate state.
Default: false.

Example HTML code 1:

This example illustrates the use of the indeterminate property:
<head>
    <script type="text/javascript">
        function Init () {
            var acceptAgreement = document.getElementById ("acceptAgreement");
            if ('indeterminate' in acceptAgreement) {
                acceptAgreement.indeterminate = true;
            }
        }

        function SubmitForm () {
            var acceptAgreement = document.getElementById ("acceptAgreement");

            if ('indeterminate' in acceptAgreement) {
                if (acceptAgreement.indeterminate) {
                    alert ("You must accept or decline the agreement!");
                    return;
                }
            }

            if (acceptAgreement.checked) {
                alert ("You accepted the agreement.");
            }
            else {
                alert ("You declined the agreement.");
            }
        }
    </script>
</head>
<body onload="Init ()">
    Try to register first!
    <form>
        <input type="checkbox" id="acceptAgreement" /> 
        <label for="acceptAgreement">I accept the User Agreement and Privacy Policy</label>
        <br /><br />
        <button onclick="SubmitForm ()">Register</button>
    </form>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content