Javascript Reference - HTML DOM Input Time form Property








The read onlyform property get the form containing the time field.

Browser Support

form Yes Yes Yes Yes Yes

Syntax

var v = timeObject.form 

Return Value

A reference to the form element containing the time field. If the time field 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="time"> element.


<!DOCTYPE html>
<html>
<body>
<!--from w  w  w . j av  a  2 s  .  com-->
<form id="myForm">
  Time: <input type="time" id="myTime">
</form>
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myTime").form.id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: