Javascript DOM HTML Input Month form Property get

Introduction

Return the id of the form containing the <input type="month"> element:

var x = document.getElementById("myMonth").form.id;

Click the button to return the id of the form the month field belongs to.

input elements with type=month is not supported in Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm">
  <input type="month" id="myMonth">
</form>//from   w  w  w. j  ava 2s. c  o m
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myMonth").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The form property returns a reference to the form containing the month field.

This property returns a form object on success.

This property is read only.

The <input type="month"> element is not supported in Firefox.

If the month field is not in a form, null is returned




PreviousNext

Related