Er.KT
Er.KT

Reputation: 2860

Don't allow to select past date and time in jquery-simple-datetimepicker

I have used jquery-simple-datetimepicker

available here

https://github.com/mugifly/jquery-simple-datetimepicker

my code is

<input name="day_time" id="day_time_input" type="text" value="" />

 jQuery(function () {
         jQuery('#day_time_input').appendDtpicker();
 });

now want to prevent user from selecting past dates.

so how do to that?

enter image description here

Upvotes: 0

Views: 2533

Answers (4)

Shawn
Shawn

Reputation: 3159

you want to add futureOnly: true

$("#div").appendDtpicker({
    futureOnly: true
});

Upvotes: 1

rojen
rojen

Reputation: 11

in the file jquery.simple-dtpicker.js

find

 var getDefaults = function() {
       return {
        "current": null,
        "dateFormat": "default",
        "locale": "en",
        "animation": true,
        "minuteInterval": 30,
        "firstDayOfWeek": 0,
        "closeOnSelected": false,
        "timelistScroll": true,
        "calendarMouseScroll": true,
        "todayButton": true,
        "dateOnly": false,
        "futureOnly": false,
        "minDate" : null,
        "maxDate" : null,
        "autodateOnStart": true,
        "minTime":"00:00",
        "maxTime":"23:59",
        "onShow": null,
        "onHide": null
    };
};

and change

 "futureOnly": true

from false to true.

Upvotes: 1

user3236908
user3236908

Reputation: 36

    <script type="text/javascript"> 
        $(function(){   
            $('*[name=date1]').appendDtpicker({
                "closeOnSelected": true,
                "futureOnly": true
            });
        });         
    </script>

use futureOnly

Upvotes: 1

Devang Rathod
Devang Rathod

Reputation: 6736

Try : datepicker is your element ID

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

Upvotes: 1

Related Questions