Return the form's id containing the <input type="date"> element:
var x = document.getElementById("myDate").form.id;
Click button to return the form's id where the date field is from.
<!DOCTYPE html> <html> <body> <form id="myForm"> A date control: <input type="date" id="myDate"> </form>/*from ww w . java 2 s . c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myDate").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The form
property returns a reference to the form containing the date field.
This property returns a form object on success.
If the date control is not in a form, null is returned
This property is read only.