0

I want to disable Next date on datepicker. In this code I am able to hide weekend dates easily but I did not find any solution for hide Next date always.

As an Example today is Date 21-04-2017 so on Datepicker Date 22-04-2017 should be hide but other dates should be active.

var newWeekends = (weekends) ? $.datepicker.noWeekends : false;
var newDaysNb = (date_nb_days == 0) ? '1' : date_nb_days;
$( function() {
$( "#datepicker" ).datepicker({
timeFormat: "hh:mm tt",
beforeShowDay:$.datepicker.noWeekends,                    
changeYear: false,  
});
});
3
  • Can you give an example, next date of what, the weekend or today Commented Apr 28, 2017 at 3:01
  • As an Example today is Date 21-04-2017 so on Datepicker Date 22-04-2017 should be hide but other dates should be active. Commented Apr 28, 2017 at 4:03
  • jsfiddle.net/arunpjohny/5mf3uLbc/1? Commented Apr 28, 2017 at 4:26

1 Answer 1

1

Update 2:
Below is the code for hiding next date:

var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var dd = tomorrow.getDate();
var mm = tomorrow.getMonth()+1; //January is 0!

var yyyy = tomorrow.getFullYear();
if(dd<10){
    dd='0'+dd;
} 
if(mm<10){
    mm='0'+mm;
} 
var today = yyyy+'-'+mm+'-'+dd;
var array = []
array.push(today);

console.log(array)
$('input').datepicker({
    language:'TR',
    beforeShowDay: function(date){
        var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
        return [ array.indexOf(string) == -1 ]
    }
});
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link href="https://davidwalsh.name/demo/jquery-ui-css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet"/>

<input type='text' id='visit' />

Sign up to request clarification or add additional context in comments.

2 Comments

I want to hide only tomorrow date always.
As an Example today is Date 21-04-2017 so on Datepicker Date 22-04-2017 should be hide but other dates should be active.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.