The month input type is used in HTML using the <input type = "month">. Using this, allow the users to select month and year. But, what if you only want to show the year popup? Well, year input type isn’t available.
To use year input type, we will be using jQuery to add datepicker. It is used with the text input type. On running the program, only the year will be visible.
You can try to run the following code to learn how to use input type to set a year
Example
<html> <head> <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"> </script> <script type="text/javascript"> $(function() { $( "#date" ).datepicker({dateFormat: 'yy'}); }); </script> </head> <body> <form action = "" method = "get"> Details:<br> <br> Student Name <br> <input type="name" name="sname"> <br> Year of Birth <br> <input type="text" id="date"> <br> <input type="submit" value="Submit"> </form> </body> </html>