Easy Tutorial
❮ Prop Link Href Prop Textarea Required ❯

Checkbox form Attribute


Definition and Usage

The form attribute returns a reference to the form that contains the checkbox.

This attribute returns a form object.

Syntax


Browser Support

All major browsers support the form attribute.


Example

The following example returns the ID of the form to which the checkbox belongs:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x = document.getElementById("myCheck").form.id;
    alert(x);
}
</script>
</head>
<body>

<form id="form1">
<input type="checkbox" id="myCheck">Do you like summer?
</form>
<button type="button" onclick="displayResult()">Display the form ID containing the checkbox</button>

</body>
</html>

❮ Prop Link Href Prop Textarea Required ❯