2016-07-18 29 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'); 
     }); 
    });