简体   繁体   中英

jQuery - Validate date on datetime picker click on SharePoint

I have developed a custom Web Part on SharePoint 2013.

I'm using the default date picker control. I also have an array with all the holidays in Italy, and I would like to "validate" the selected date just after the user clicks on the datetimepicker. Validate in my case should be print an alert message if the selected date is a holiday.

I've tried this code, but it is not firing:

$(".ms-picker-table a").on("click",function() {
    console.log("ON CLICK DATEPICKER");
    /* DATES CHECK */
    [...]
});

ms-picker-table is the class of the date picker control.

a elements inside this table already contain code in href attribute:

javascript:ClickDay('01\u002f06\u002f2017')

I don't know if it can create problems.

Also parent td element of each link has this code:

onclick="javascript:ClickDay('01\u002f06\u002f2017')"

So is there a way to correct my code to check dates when a user select a value from datepicker?

onBlur event should do the job

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="date" id="dateField"> <script> $("input[id*='dateField']").blur(function(){ var dateValue=$("input[id='dateField']").val(); console.log(dateValue); // check array to see if the date is in the Array }); </script> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM