2016-07-18 34 views
1

我想在引导程序datepicker之前禁用今天之前的所有日期。我挖了互联网,每个人都有这个解决方案,但为什么它不能在我的代码中工作?bootstrap jquery minDate不工作

<input type="text" id="date"/> 
$(window).load(function(){ 
    $('#date').datepicker({ 
     minDate:0 
    }); 
}); 
+0

的[的minDate不是在引导日期选择器工作]可能的复制(http://stackoverflow.com/questions/19219713/mindate-not-working-in-bootstrap-datepicker) – ankit

+0

的minDate 0为什么呢?它可能是今天的全日期字符串吗? –

+0

@ankit我甚至尝试了可能的重复你的建议startDate。它仍然不工作! –

回答

1
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title></title> 
<link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="Stylesheet" 
    type="text/css" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 
<script language="javascript"> 
    $(document).ready(function() { 
     $("#txtdate").datepicker({ 
      minDate: 0 
     }); 
    }); 
</script> 
</head> 
<body> 
Date : 
<input id="txtdate" type="text"> 
</body> 
</html> 
+0

请发表一些有用的东西! –

+0

好的,我想要完整的代码?我会提供。 – Ranjan

+0

再次检查我更新了我的代码。否则,粘贴您的完整代码,以便任何人都可以修改它。 – Ranjan

0

试试这个!

/* Apply the right format to the minDate option */ 
    $(document).ready(function() { 
     $("#txtdate").datepicker({ 
      minDate: new Date('12/12/2016'); 
     }); 
    });