HTML DOM Input DatetimeLocal form Property



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 −

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

140 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements