How to use year input type in HTML?

HTMLWeb DevelopmentFront End Technology

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


Live Demo

      <script src="">
      <script type="text/javascript">
         $(function() {
            $( "#date" ).datepicker({dateFormat: 'yy'});
      <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">
Published on 07-Feb-2018 12:43:17