I am trying to customize the SharePoint calendar in a way, I want to deny the user from adding meetings on specific day and specific hours when clicking on add. how can I achieve that out of the box , if not how can that be done in a custom way .


There is no OOB way to do this. Two options:

Option 1:

create an event handler (itemAdding) and check if your validation logic is met, otherwise cancel the insertion.

Option 2:

Leverage the javascript PreSaveItem function. Something like (requires jQuery):

function PreSaveItem(){
    var $start = $('[title="Start Time"]');
    var $end = $('[title="End Time"]');

    var starDate = $start.val();
    var startHour = $start.parents('tr:first').find('select:first').val();
    var startMinutes = $start.parents('tr:first').find('select:last').val();

    var endDate = $end.val();
    var endHour = $end.parents('tr:first').find('select:first').val();
    var endMinutes = $end.parents('tr:first').find('select:last').val();

    //your validation logic here

    if (!validationPassed){
        alert('You cannot add events on this time frame');
        return false;
    return true;

When working with dates in javascript, I always recommend using the excellent moment.js library

  • Yes, you can try the Option 2 - PreSave – variable Mar 13 '14 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.