Syntax error HTML DOM Input Date form Property

HTML DOM Input Date form Property



The Input Date form property returns the reference of enclosing form for input date.

Syntax

Following is the syntax −

  • Returning reference to the form object
inputDateObject.form

Example

Let us see an example of Input Date form property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Date Form</title>
</head>
<body>
<form id="formForDateInput">
Date Select: <input type="date" id="Date" >
</form>
<button onclick="getFormID()">Get Form ID</button>
<div id="divDisplay"></div>
<script>
   function getFormID() {
      var inputDate = document.getElementById("Date");
      var divDisplay = document.getElementById("divDisplay");
      divDisplay.textContent = 'Form ID for date input: '+inputDate.form.id;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Get Form ID’ button −

After checking ‘Get Form ID’ button −

Updated on: 2019-07-30T22:30:26+05:30

123 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements