hello i want to see an alert from browser for Sharepoint online event calendar.. how can i do this ? When i add an event set to past date then an alert warns me "past day event" later open to new event modal.. *with pure script. Does anyone do similar? enter image description here

1 Answer 1


hello everyone i solved the problem, First of all, I would like to point out that we need to write the script we are going to write inside the modal. script:

function PreSaveItem() {

var UserDate = document.getElementById("ctl00_ctl34_g_edc3892a_ea11_4e2e_b0e6_1943c7cef962_ctl00_ctl05_ctl03_ctl00_ctl00_ctl05_ctl00_ctl00_DateTimeField_DateTimeFieldDate").value;

var UserDateReverse = UserDate.split(".").reverse();

var dd1 = String(UserDateReverse[2]).padStart(2, '0');
var mm1 = String(UserDateReverse[1]).padStart(2, '0');
var yyyy1 = String(UserDateReverse[0]).padStart(2, '0');

var selectDate = yyyy1 + mm1 + dd1;

var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = String(today.getFullYear());

today = yyyy + mm + dd;  

    if (selectDate < today) {
          alert("past day event!!!");
          return false;
    return true;


I found PreSaveItem() function for save new event button.

enter image description here enter image description here

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.