0
var birthDate;
$(function() {
var currentDate = new Date();
$("#BirthDate").datepicker({
dateFormat: "mm/dd/yy",
showOn: "button",
buttonImage: "../Images/cal.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
maxDate: currentDate,
yearRange: "-90:+10",
onSelect: function(dateText, inst) { birthDate = dateText;}
});
});
$(function() {
var currentDate = new Date();
$("#MaritalStatusDate").datepicker({
dateFormat: "mm/dd/yy",
showOn: "button",
buttonImage: "../Images/cal.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
minDate: birthDate,
maxDate: currentDate,
yearRange: "-90:+10"
});
});
在上面的代码中,我试图根据$("#BirthDate")
中选择的日期禁用$("#MaritalStatusDate")
日期。我正在使用BirthDate
中的onSelect
事件来标识所选日期,并将该值存储在全局声明的变量中。使用变量我已设置minDate
在$("#MaritalStatusDate")
。但日期并没有根据minDate
价值被禁用。在为变量赋值时是否需要更改日期格式?任何人都可以帮助我这样做吗?动态禁用日期在jQuery日期选择器
嗨威廉。我使用了你的脚本,但当点击提交按钮并返回到视图时,日期选择器不显示。 –
@kavithaReddy,我不确定你的意思。你能通过jsfiddle来说明吗? –