How can I disable weekends (saturdays and sundays) from date picker?

Confluence User - 23 Oct, 2016

Hi 

How can i disable weekends from the date picker. I have two date pickers "From" and "Till" and a "text box" for calculating the difference of the these two dates (using java script). I would also like this to reflect in the calculation.

JavaScript code for calculating the date difference 

<script type="text/javascript">
$('input[name="leavePeriodFrom"], input[name="leavePeriodTo"]').change(function(){
d1 = $('input[name="leavePeriodFrom"]').datepicker('getDate');
d2 = $('input[name="leavePeriodTo"]').datepicker('getDate');
diff = 0;
if (d1 && d2) {
diff = 1+Math.floor((d2.getTime() - d1.getTime())/ 86400000); // ms per day
}
$('input[name=days]').val(diff);
document.getElementById('days').readOnly = true;
});
</script>

 

Many  thanks in advance.

Kamran

datepicker

1


24 Oct, 2016
confluenceUser
confluenceUser

Hi Kamran Raza

Thank you for your question but the javascript communitymight be able to help you, example here.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print