Return the id of the form containing the <input type="week"> element:
var x = document.getElementById("myWeek").form.id;
Click the button to return the id of the form the week field belongs to.
input elements with type="week" are not supported in Internet Explorer or Firefox.
<!DOCTYPE html> <html> <body> <form id="myForm"> <input type="week" id="myWeek"> </form>/*from w ww. j a v a 2 s . c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myWeek").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The form property returns a reference to the form containing the week field.
This property returns a form object on success.
This property is read only.
The <input type="week"> element is not supported in Firefox.
If the week field is not in a form, null is returned