HTML DOM Input DatetimeLocal name Property


The HTML DOM Input DatetimeLocal name property returns a string, which is the value of the name attribute of input datetimeLocal. User can also set it to a new string.

Syntax

Following is the syntax −

  • Returning string value
inputDatetimeLocalObject.name
  • Setting name attribute to a string value
inputDatetimeLocalObject.name = ‘String’

Example

Let us see an example of Input DatetimeLocal name property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal name</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>
<fieldset>
<legend>Datetime-Local-name</legend>
<label for="datetimeLocalSelect">Today :
<input type="datetime-local" id="datetimeLocalSelect" value="2019-05-23T12:45" name="Rupenzel">
</label>
<input type="button" onclick="getnameimum()" value="Who's DOB is this? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
   function getnameimum() {
      if(inputDatetimeLocal.value === '2019-05-23T12:45')
         divDisplay.textContent = 'Above DOB is of '+inputDatetimeLocal.name;
      else
         divDisplay.textContent = 'Above DOB is of no one!';
   }
</script>
</body>
</html>

This will produce the following output −

Output

Before clicking ‘Who’s DOB is this?’ button −

After clicking ‘Who’s DOB is this?’ button −

Updated on: 30-Jul-2019

34 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements