Textinput Date, Month and Week



Description

Date input type attribute allows the user to input date (year, month, day) encoded according to ISO 8601.

Month input type allows the user to select date consisting of a year and a month encoded according to ISO 8601.

Week input allows the user to select date consisting of a year and a week number encoded according to ISO 8601.

Example

Following example demonstrates the use of date, month and week input in the jQuery Mobile.

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <form>
         <h2>Date Input Example</h2>
         <label for = "src">Date Input</label>
         <input type = "date" id = "src" data-clear-btn = "false">
         
         <label for = "src1">Clear the Date input Field</label>
         <input type = "date" data-clear-btn = "true" id = "src1">

         <h2>Month Input Example</h2>
         <label for = "src2">Month Input</label>
         <input type = "month" id = "src2" data-clear-btn = "false">
         
         <label for = "src3">Clear the Month input Field</label>
         <input type = "month" data-clear-btn = "true" id = "src3">

         <h2>Week Input Example</h2>
         <label for = "src4">Week Input</label>
         <input type = "week" id = "src4" data-clear-btn = "false">
         
         <label for = "src5">Clear the Week input Field</label>
         <input type = "week" data-clear-btn = "true" id = "src5">
      </form>
   </body>
</html>

Output

Let's carry out the following steps to see how the above code works −

  • Save the above html code as textinput_date_month_week.html file in your server root folder.

  • Open this HTML file as http://localhost/textinput_date_month_week.html and the following output will be displayed.

jquery_mobile_widgets.htm
Advertisements