当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Set minimum time and max time in timepicker not working

问题描述:

I am using timepicker for setting breaktime in an input field.I need to set minTime and maxTime options in this timepicker field.This field will get hourMin and hourMax from other two input fields named from-time field and to-time field.

Suppose the from-time field has 08:15am and to-time field has '12:30pm',

I will make the timepicker option for the breaktime input field ,hourMin to 8 and hourMax to 12.But the minute slider will start from 00 to 59.But if the selected time is 8,then the minute slider should start from 15 only,and in case of selected time is 12,it should allow users to 30 only.

<td>

from

<input type = "text" id="fromdate0" name = "fromdate0"

class= 'timepicker2 fromdate' readonly="readonly">

to

<input type='text' name='todate0' id='todate0'

class='timepicker2 todate' readonly="readonly">

<input type = "text" id="frombreak0" name = "frombreak0" class= 'timepicker2 frombreak' style='width: 45px;' readonly="readonly" >

$('.frombreak').click(function(){//

var elementno = parseInt($(this).prop('id').replace(/[^0-9\.]/g, ''),10);

var min_hour = $('#fromdate'+elementno).val().split(':')[0].replace(/^0+/, '');

var max_hour = $('#todate'+elementno).val().split(':')[0].replace(/^0+/, '');

$('#'+$(this).prop('id')).timepicker({

hourGrid: 3,

minuteGrid: 10,

stepMinute: 5,

minTime:'08:00 am',

maxTime:'12:30 pm',

hourMin: parseInt(min_hour),//the value is 8

hourMax: parseInt(max_hour),//value will be 12

timeOnlyTitle: 'Choose From time',

timeText: 'Selected From Time &nbsp;',

timeFormat: 'HH:mm'

});

$('#'+$(this).prop('id')).timepicker('show');

});

The minimum and max time limit is working.From the document,I have found that minTime is used for setting minTime.Please help me.

分享给朋友:
您可能感兴趣的文章:
随机阅读: