Page 1 of 1
How do I disable certain dates on date picker?
Posted: 19 Nov 2019
by thebrightlord
Not seeing documentation on how to do that, just for disabling entire fields...
I tried this code:
function setToDateRange() {
fd.field('Effective_x0020_Date').control('kendoDateTimePicker')
.done(function(picker) {
picker.setOptions({
min: 2,
max: 30
});
});
Didn't work
Re: How do I disable certain dates on date picker?
Posted: 20 Nov 2019
by mnikitina
Hello thebrightlord,
You can disable specific dates in the month with the following code. Replace 'Date' with the internal name of your field. If you use Date Only fields, replace 'kendoDateTimePicker' with 'kendoDatePicker'.
Code: Select all
fd.field('Date').control('kendoDateTimePicker').done(function(picker) {
picker.setOptions({
value: new Date(),
disableDates: function (date) {
var disabled = [2,30];
if (date && disabled.indexOf(date.getDate()) > -1 ) {
return true;
} else {
return false;
}
}
});
});
Re: How do I disable certain dates on date picker?
Posted: 20 Nov 2019
by thebrightlord
Thank you Margarita.
Your code sparked an idea and I modified it to this:
Code: Select all
var today = new Date();
var minDate = today.setDate(today.getDate()+2);
var maxDate = today.setDate(today.getDate()+30);
fd.field('Effective_x0020_Date').control('kendoDatePicker').done(function(picker) {
picker.setOptions({
min: new Date(minDate),
max: new Date(maxDate)
})
});
I needed to only allow 2 days past today as minimum and 30 days past today as maximum.
Re: How do I disable certain dates on date picker?
Posted: 12 Mar 2020
by Tanja1980
I have similar issue, but I can't get the code to work...
I have Date Picker field, but in Related Items in Quick Edit Mode and need to allow entries for only the past 3 days.
I tried both upper codes (I even replaced fd.field with fd.relatedItems), but no succes. Does the code differ, if the field is in Related Items?
Regards,
Tanja
Re: How do I disable certain dates on date picker?
Posted: 16 Mar 2020
by mnikitina
Hello Tanja1980,
I'm sorry for the delay in reply!
This approach is not applicable to the Date column in related items. And It is not possible to interact with Related items in quick edit mode using JS.
But you can try out the SharePoint column validation. Please find more information in this article:
https://support.office.com/en-us/articl ... 7ebf6988b3
And in this post:
https://sharepoint.stackexchange.com/qu ... odays-date