Hullo, I am working with a datepicker that allows users to enter a date schedule for given tasks.

However, I want the dates that have passed to be disabled from the datepicker, so that the user only selects a future date.
Here is what I am using currently;

<script type="text/javascript">
                        $(function() {
                            //var altFormat = $( "#datepicker" ).datepicker( "option", "altFormat" );
                            $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd',changeYear:true,changeMonth:true,yearRange:'1900:2002'});
                            //getter
                            var dateFormat = $( "#datepicker" ).datepicker( "option", "dateFormat" );
                            //setter
                            $( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
                        });

hai Webville312,

i think u need to set the minDate property for achieving this like as follows (incase if you are using Jquery Datepicker)

$("#datepicker").datepicker({ minDate: 0 });

let me know the status

happy coding

I have tried that out, but there is no difference ... the dates are all still enabled ...

I dunno but is it me who is writing it wrong?? Here is the code I am using right now;

   <script type="text/javascript">
                        $(function() {
                            //var altFormat = $( "#datepicker" ).datepicker( "option", "altFormat" ).datepicker({ minDate: 0 });
                            $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd',changeYear:true,changeMonth:true,yearRange:'1900:2002'});
                            //getter
                            var dateFormat = $( "#datepicker" ).datepicker( "option", "dateFormat" );
                            //setter
                            $( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
                        });

Any more ideas ...?

This is my aproach on a needed way, check this out.

            $('.' + obj + ' .deliv_date').datepicker({
                dateFormat: "yy-mm-dd", 
                showButtonPanel: true,
                beforeShow: function(input, inst) {
                    var calendar = inst.dpDiv;
                    setTimeout(function() {
                        calendar.position({
                            my: 'right top',
                            at: 'right bottom',
                            collision: 'none',
                            of: input
                        });
                    }, 1);
                },
                changeYear: true,
                changeMonth: true,
                minDate: 0,
                beforeShowDay: $.datepicker.noWeekends,
                numberOfMonths: 1
            });

hai Webville312

you havn't set the minDate Property in your code
try to change your code as follows its work fine for myside

$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd',changeYear:true,minDate:0,changeMonth:true,yearRange:'1900:2002'});

check it once and let me know the status
happy coding

[edited]

Thanx radhakrishna [Hope I got that right].
It worked like a charm ....

Thanx once again.

Thank you all for your contributions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.