Ok, so I have a calendar and I want to highlight specific days that come from a json
Jquery calendar
json
public async Task OnGetLoadDaysCMPAsync()
{
var data = await _context.CMPAvDates.Select(s => s.CMPDate).ToListAsync();
return new JsonResult(data);
}
but how do I highlight days from json in calendar?

Naimish MakwanaPosted Jan 24, 2023, 7:13 AM
Try below code with your date formate.
Please accept answer if its useful.
Thanks
Marius VasilePosted Jan 24, 2023, 8:30 AM
Final working script, also with disabling weekend
Marius VasilePosted Jan 24, 2023, 7:23 AM
Thank you Naimish, that worked.
Marius VasilePosted Jan 24, 2023, 7:06 AM
Sachin, thank you. I added
to my _Layout page but I have no change in script behavior
Marius VasilePosted Jan 24, 2023, 7:04 AM
Thank you Naimish, they way you have it works but my json does not give me dates in that format. Result from json is
2023-01-25T00:00:00,2023-01-24T00:00:00,2023-01-26T00:00:00 (yy-mm-dd)
btw, when I tried
was not working. Why?
Naimish MakwanaPosted Jan 24, 2023, 6:37 AM
Hello Marrius,
Below is working code. Please check.
Thanks
Naimish Makwana
Sachin SinghPosted Jan 24, 2023, 6:33 AM
Try to use moment.js for date format
Marius VasilePosted Jan 24, 2023, 6:11 AM
Thank you Naimish, my function works very well if array is like
var unavDates = ["2023-01-23", "2023-01-24", "2023-01-25"], I can't manage to converse date type 2023-01-25T00:00:00
Anyway, I implemented your suggestion like
but I have no highlight in calendar. array unavDates output is
2023-01-25T00:00:00,2023-01-24T00:00:00,2023-01-26T00:00:00
What am I doing wrong?
Thank you
Naimish MakwanaPosted Jan 24, 2023, 3:34 AM
Hello Marrius,
Please try below code.
You can change the date formate as below.
CSS
Reference link for detail :
https://makitweb.com/how-to-highlight-selected-date-in-jquery-ui-datepicker/#:~:text=Define%20beforeShowDay%20within%20datepicker(),%5D%3B%20otherwise%20return%20%5Btrue%5D%20.
Thanks
Marius VasilePosted Jan 23, 2023, 6:06 PM
I think I know where the problem is. json gets data in this format
2023-01-25T00:00:00,2023-01-24T00:00:00,2023-01-26T00:00:00
and I use
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
But how it should look like?
Marius VasilePosted Jan 23, 2023, 4:09 PM
So, the below script works but the final part is not working despite json provide data
This (unavDates.indexOf(string) == -1) suposed to highlight the dates from json but is not
Marius VasilePosted Jan 23, 2023, 3:06 PM
Thank you Pasang, I will try. I had this function but there is something wrong with it
Pasang TamangPosted Jan 23, 2023, 3:02 PM
Hi,
I would suggest to use beforeShowDay option. Please check below link for more detail and example
https://www.geeksforgeeks.org/jquery-ui-datepicker-beforeshowday-option/
Regards,
Pasang