jQuery DateTime Picker Set MinDate动态 [英] jquery datetime picker set minDate dynamic
本文介绍了jQuery DateTime Picker Set MinDate动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用trentrichardson.com的datetimepicker.
I guys i'm using a datetimepicker by trentrichardson.com.
我有一个带有两个输入字段的表单: from 和 to ,我希望能够将minDate动态设置为等于该值的"to"字段我的发件人"字段中.
I have a form with two input fields : from and to and i want to be able to set dynamically a minDate to my "to" field equal to the value of my "from" field.
我知道我应该使用beforShow选项,但不知道如何实现该功能.
I know i should use a beforShow option but don't know how to implement the function.
$('.from,.to').datetimepicker({
beforeShow: customRange
});
已编辑/解决方案
function customRange(input) {
if (input.id == 'to') {
var x=$('#from').datepicker("getDate");
$( ".to" ).datepicker( "option", "minDate",x );
}
else if (input.id == 'from') {
var x=$('#to').datepicker("getDate");
$( ".from" ).datepicker( "option", "maxDate",x );
} }
推荐答案
您可以使用setter和getter动态设置和获取minDate:
you can set and get minDate dynamically with setter and getter:
//getter
var minDate = $( ".selector" ).datepicker( "option", "minDate" );
//setter
$( ".selector" ).datepicker( "option", "minDate", new Date(2007, 1 - 1, 1) );
这篇关于jQuery DateTime Picker Set MinDate动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文