jQuery Mobile - Textinput Time and Color



Description

Time input type allows the user to input time (hour, minute, seconds, fractional seconds) encoded according to ISO 8601.

Color input type allows the user to select a particular color from the displayed color box.

Example

Following example demonstrates the use of time and color 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>Time Input Example</h2>
         <label for = "src">Time Input</label>
         <input type = "time" id = "src" data-clear-btn = "false">
         
         <label for = "src1">Clear the Time Field</label>
         <input type = "time" data-clear-btn = "true" id = "src1">

         <h2>Color Input Example</h2>
         <label for = "src2">Color Input</label>
         <input type = "color" id = "src2" data-clear-btn = "false">
         
         <label for = "src3">Clear the Color Field</label>
         <input type = "color" data-clear-btn = "true" id = "src3">
      </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_time_color.html file in your server root folder.

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

jquery_mobile_widgets.htm
Advertisements