close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Disabling one date in Datepicker

Thread began 8/22/2015 9:43 am by Mags | Last modified 8/24/2015 10:09 am by Ray Borduin | 465 views | 2 replies |

Mags

Disabling one date in Datepicker

I have a datepicker field which is currently set to only allow the selection of Fridays. I've been asked to also disable Friday 28 August - how would I amend the code to do this? Current code as follows:

$(function(){
$('#Date').datepicker({
beforeShowDay: nonWorkingDates,
changeMonth: true,
changeYear: true,
dateFormat: 'dd M yy',
onClose: closeDatePicker_Date
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDays = [[Sunday],[Monday],[Tuesday],[Wednesday],[Thursday],[Saturday]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
return [true];
}
});
Sign in to reply to this post

Ray BorduinWebAssist

$(function(){
$('#Date').datepicker({
beforeShowDay: nonWorkingDates,
changeMonth: true,
changeYear: true,
dateFormat: 'dd M yy',
onClose: closeDatePicker_Date
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDays = [[Sunday],[Monday],[Tuesday],[Wednesday],[Thursday],[Saturday]];
var closedDates = [[8, 28, 2015]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
for (var i = 0; i < closedDates.length; i++) {
if (date.getDate() == closedDates[i][0] && date.getMonth() + 1 == closedDates[i][1] && date.getFullYear() == closedDates[i][2]) {
return [false];
}
}
return [true];
}
});
Sign in to reply to this post
Did this help? Tips are appreciated...

Mags

Thanks for that Ray, I had to change the date order so that it would work with my UK date format:

var closedDates = [[28, 8, 2015]];

and it now works great, thanks!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...