0

This is my first question on stckoverflow so I hope I'm asking right.

On my website i'm using a jquery datepicker. This works fine. However, I need the following addon: - When a user selects a date which is a specific date (var specificDate), alert with hello world.

This code already triggers the alert when selecting a date. However I am not able to figure out how to compare the "var date" with the array of specifc dates.

onSelect: function(dateText, inst){
     var date = $(this).datepicker('getDate');  
     var specificDate = ["12-12-2013","11-12-2013"];

     for (i=0; i < specificDate.length; i++){
     if (date == specificDate [i]){
          alert("hello world");
        }
          }
     });

I think I need to know more about the date formats. My question is to get me a bit further with this how to make the comparison.

Thank you in advance!

djduck
  • 1

1 Answers1

0

Reference

if ($.datepicker.parseDate('dd-mm-yy', specificDate[0]) > $.datepicker.parseDate('dd-mm-yyyy', specificDate[1])){
       alert(specificDate[0] + 'is later than ' + specificDate[1]);
}
Community
  • 1
  • 1
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
  • Dear Naveen. thank you for your quick answer. I think I did not describe my prolem well. the if statement needs to check if the already known selected date (date) is equal to one of the dates in the array (specificDate). I hope you can help me out. Thanks in advance! – djduck Sep 21 '13 at 12:36