HTML DOM Input Datetime form Property



The HTML DOM Input Datetime form property returns the reference of enclosing form for input datetime.

Syntax

Following is the syntax −

Returning reference to the form object

inputDatetimeObject.form

Example

Let us see an example of Input Datetime form property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Datetime form</title>
</head>
<body>
<form id="dateTimeForm">
Date & Time: <input type="datetime" id="Datetime" value="2009-12-19T12:48Z">
</form>
<button onclick="getFormID()">Get Form ID</button>
<div id="divDisplay"></div>
<script>
   function getFormID() {
      var inputDatetime = document.getElementById("Datetime");
      var divDisplay = document.getElementById("divDisplay");
      divDisplay.textContent = 'Form ID for datetime input: '+inputDatetime.form.id;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Get Form ID’ button −

After checking ‘Get Form ID’ button −


Advertisements