• We just launched and are currently in beta. Join us as we build and grow the community.

Simple jQuery Time Picker

moutrix10

Sponsored Content Strategist
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
147
Likes
184
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
In this article, we are going to learn how to create Simple jQuery Time Picker on your web page. We are going to use simple and lightweight jQuery plugin to create this. It consists a 24-Hour or 12-Hour format from your time picker to your text field when the user clicks on. Download the full source code below then try it. Let’s start to code.

How to create it

  1. Copy and paste this jQuery library link to your HEAD tag of your web page.
    1. <link

      rel

      =

      "stylesheet"

      href

      =

      "stylesheets/wickedpicker.css"

      >
    2. <script

      src

      =

      "jquery-1.12.4.min.js"

      ></

      script

      >
    3. <script

      type

      =

      "text/javascript"

      src

      =

      "src/wickedpicker.js"

      ></

      script

      >
  2. Choose your desired text field to insert the time picker plugin and we’re done.
    1. <

      script type=

      "text/javascript"

      >
    2. $(

      '.timepickerA'

      )

      .wickedpicker

      (

      {

      now:

      '15:30'

      ,

      twentyFour:

      true

      ,

      title:
    3. 'Time Picker A'

      ,

      showSeconds:

      true

      }

      )

      ;
    4. </

      script>
  3. And, this is the default plugin settings that we have.
    1. <

      script>
    2. var

      today =

      new

      Date

      (

      )

      ;

    3. var

      pluginName =

      "SimpleTimePicker"

      ,
    4. defaults =

      {
    5. now:

      today.getHours

      (

      )

      +

      ':'

      +

      today.getMinutes

      (

      )

      ,
    6. twentyFour:

      false

      ,
    7. upArrow:

      'SimpleTimePicker__controls__control-up'

      ,
    8. downArrow:

      'SimpleTimePicker__controls__control-down'

      ,
    9. close:

      'SimpleTimePicker__close'

      ,
    10. hoverState:

      'hover-state'

      ,
    11. title:

      'Simple Time Picker'

      ,
    12. showSeconds:

      false

      ,
    13. secondsInterval:

      1

      ,
    14. minutesInterval:

      1

      ,
    15. beforeShow:

      null

      ,
    16. show:

      null

      ,
    17. clearable:

      false
    18. }

      ;
    19. </

      script>
  4. Markup for two text field. Copy and paste to your BODY tag of your web page.
    1. <h2

      >
    2. Simple jQuery Time Picker
    3. </

      h2

      >
    4. <label

      for

      =

      "timepickerA"

      >

      Time A in 24-Hour Format</

      label

      >
    5. <br

      /

      >
    6. <br

      /

      >
    7. <input

      type

      =

      "text"

      id

      =

      "timepickerA"

      name

      =

      "timepickerA"

      class

      =

      "timepickerA"

      >
    8. <br

      /

      >
    9. <br

      /

      >
    10. <label

      for

      =

      "timepickerB"

      >

      Time B in 12-Hour Format</

      label

      >
    11. <br

      /

      >
    12. <br

      /

      >
    13. <input

      type

      =

      "text"

      id

      =

      "timepickerB"

      name

      =

      "timepickerB"

      class

      =

      "timepickerB"

      >

That's it, kindly click the "Download Code" button below for the full source code. And try it to customize your Time Picker. Enjoy coding.

Output

24-Hour Format Time Picker
24.jpg

12-Hour Format Time Picker
12_0.jpg


Hope that this simple yet useful article that I created may help you to your future projects.

Share us your thoughts and comments below. Thank you so much for dropping by and reading this article post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

335,120

335,128

Top