The read only form
property returns a reference to the form containing the datetime field.
form |
No | No | No | No | No |
var v = datetimeObject.form
A reference to the form element containing the datetime field. If the date control is not in a form, null is returned.
The following code shows how to get the id of the form containing the <input type="datetime"> element.
<!DOCTYPE html>
<html>
<body>
<form id="myForm">
A date control: <input type="datetime" id="myDatetime">
</form><!--from ww w.j a v a 2 s .com-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myDatetime").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: