HTML DOM Input DatetimeLocal form Property

HTMLWeb DevelopmentFront End Technology

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

Syntax

Following is the syntax −

Returning reference to the form object

inputDatetimeLocalObject.form

Example

Let us see an example of Input DatetimeLocal form property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal form</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form id="Mathematics">
<fieldset>
<legend>Datetime-Local-form</legend>
<label for="datetimeLocalSelect">Examination Time:
<input type="datetime-local" id="datetimeLocalSelect" value="2019-09-01T09:00">
</label>
<input type="button" onclick="showExamination()" value="Which exam is on this date? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
   function showExamination() {
      divDisplay.textContent = 'Exam: '+inputDatetimeLocal.form.id;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Which exam is on this date?’ button −

After checking ‘Which exam is on this date?’ button −

raja
Published on 24-Jul-2019 11:24:11
Advertisements