Javascript Reference - HTML DOM Input Date form Property








The read only form property returns a reference to the form containing the date field.

Browser Support

form Yes No No Yes Yes

Syntax

var v = inputdateObject.form 

Return Value

A reference to the form element containing the date field. If the date control is not in a form, null is returned.





Example

The following code shows how to get the id of the form containing the <input type="date"> element.


<!DOCTYPE html>
<html>
<body>
<!--from  w w  w.  ja  v a  2 s.  c o m-->
<form id="myForm">
A date control: <input type="date" id="myDate">
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myDate").form.id;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows: