1

I want to disable all dates before today in a bootstrap datepicker. I have digged the internet and everyone has this solution but why is it not working in my code?

<input type="text" id="date"/>
$(window).load(function(){
   $('#date').datepicker({
        minDate:0
   });
});
Mohammad
  • 21,175
  • 15
  • 55
  • 84
Shahbaz Pothiawala
  • 1,175
  • 5
  • 20
  • 38

2 Answers2

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>
Ranjan
  • 929
  • 1
  • 6
  • 19
  • check once again I updated my code. Otherwise paste your complete code so that anyone can modify it. – Ranjan Jul 18 '16 at 13:02
  • doesnt work. possibly i am using bootstrap 2 in which this mindate doesnt work. Do you have a solution for bootstrap 2. – Shahbaz Pothiawala Jul 18 '16 at 13:16
  • 1
    I am confused so that I am telling you if its possible just add some more code so then only I can verify it otherwise its very difficult to find-out. – Ranjan Jul 18 '16 at 13:26
  • http://jsfiddle.net/mayooresan/ZL2Bc/ here is a simple example in jquery. – Ranjan Jul 18 '16 at 13:29
0

Try this!

    /* Apply the right format to the minDate option */
    $(document).ready(function () {
        $("#txtdate").datepicker({
            minDate: new Date();
        });
    });
Johnsackson
  • 439
  • 2
  • 7