jQuery TimePicker demo - constraining time entries

A jQuery TimePicker demo showing how to constrain the valid time entries

by wvega

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
<h1>jQuery TimePicker Demo</h1>

<br/>

<p>This timepicker will show and allow time entries between 8:00 AM and 6:00 PM only.</p>

<div>
    <input id="tp1" class="timepicker" name="timepicker" />
</div>

<a href="http://github.com/wvega/timepicker"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>

CSS

body {
    background: #EFEFEF;
    padding: 20px;
}
h1 {
    font-weight: bold;
    margin-top: 100px;
}
p {
    margin: 10px 0;
}

JavaScript

$(document).ready(function(){
    // initialize both timepickers at once
    var timepicker = $('input.timepicker').timepicker({
        timeFormat: 'hh:mm p',
        // year, month, day and seconds are not important
        minTime: new Date(0, 0, 0, 8, 0, 0),
        maxTime: new Date(0, 0, 0, 18, 0, 0),
        // items in the dropdown are separated by at interval minutes
        interval: 10,
    });
});