我希望今天在Jquery Ui Datepicker
之后禁用所有未来日期以下是Demo:
代码:
$( "#start_date" ).datepicker(
{
maxDate: '0',
beforeShow : function()
{
jQuery( this ).datepicker('option','maxDate', jQuery('#end_date').val() );
},
altFormat: "dd/mm/yy",
dateFormat: 'dd/mm/yy'
}
);
$( "#end_date" ).datepicker(
{
maxDate: '0',
beforeShow : function()
{
jQuery( this ).datepicker('option','minDate', jQuery('#start_date').val() );
} ,
altFormat: "dd/mm/yy",
dateFormat: 'dd/mm/yy'
}
);
答案 0 :(得分:75)
试试这个
$(function() {
$( "#datepicker" ).datepicker({ maxDate: new Date() });
});
或者您可以使用以下方式实现此目的:
$(function() {
$( "#datepicker" ).datepicker({ maxDate: 0 });
});
答案 1 :(得分:4)
就我而言,我已将此属性赋予输入标记
Assets
答案 2 :(得分:4)
这对我有用+-------------------+----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Operator | Estimated Rows | Variables | Other |
+-------------------+----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +ProduceResults | 40 | anon[311], anon[329], anon[335], relevantNumberOfPublications, expert, expert.name, ... | |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Projection | 40 | expert.name, relevantNumberOfPublications -- anon[311], anon[329], anon[335], ... | {expert.name : , relevantNumberOfPublications : } |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Top | 40 | anon[311], anon[329], anon[335], relevantNumberOfPublications, expert, relevantNumberOfTags | anon[335]; 40 |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Projection | 3243 | anon[329], anon[335] -- anon[311], relevantNumberOfPublications, expert, relevantNumberOfTags | { : expert.name, : relevantNumberOfPublications@255} |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Filter | 3243 | anon[311], relevantNumberOfPublications, expert, relevantNumberOfTags | anon[311] |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Projection | 4324 | anon[311] -- relevantNumberOfPublications, expert, relevantNumberOfTags | {expert : expert, relevantNumberOfTags : relevantNumberOfTags, relevantNumberOfPublications@255 : relevantNumberOfPublications@255, : relevantNumberOfTags = { AUTOINT1}} |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +EagerAggregation | 4324 | relevantNumberOfPublications, relevantNumberOfTags -- expert | expert |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +F ilter | 18695308 | anon[22], anon[62], expert, publication, tag | tag.name IN { AUTOLIST0}; tag:Tag |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Expand(All) | 20141244 | anon[62], tag -- anon[22], expert, publication | (publication)-[:HAS_TAG]->(tag) |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Filter | 454092 | anon[22], expert, publication | publication:Publication |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +Expand(All) | 454092 | anon[22], publication -- expert | (expert)-[:PUBLISHED]->(publication) |
| | +----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| +NodeByLabelScan | 304114 | expert | :Expert |
+-------------------+----------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
endDate: "today"
答案 3 :(得分:3)
你可以简单地这样做
$(function() {
$( "#datepicker" ).datepicker({ maxDate: new Date });
});
仅供参考:在检查documentation时,发现它也接受数值。
数字:从今天开始的几天。例如2代表两天 从今天开始,-1代表昨天。
所以0
代表今天。因此你也可以这样做
$( "#datepicker" ).datepicker({ maxDate: 0 });
答案 4 :(得分:2)
将maxDate更改为当前日期
maxDate: new Date()
它会将当前日期设置为最大值。
答案 5 :(得分:1)
如果要附加Dtpicker,请使用以下代码
$('#enddate').appendDtpicker({
"dateOnly": true,
"dateFormat": "YYYY-MM-DD",
"closeOnSelected": true,
maxDate: new Date()
});
答案 6 :(得分:1)
//禁用当前日期之后的未来日期
$("#datepicker").datepicker('setEndDate', new Date());
//禁用当前日期之后的过去日期
$("#datepicker").datepicker('setEndDate', new Date());
答案 7 :(得分:0)
datepicker没有maxDate作为选项。我使用了endDate选项。效果很好。
> $('.demo-calendar-default').datepicker({
> autoHide: true,
> zIndex: 2048,
> format: 'dd/mm/yyyy',
> endDate: new Date()
> });
答案 8 :(得分:-4)
maxDate: new Date()
它的工作正常我在日期范围选择器中禁用当前日期