Hi All,
This may be a bug, or I may be doing something incorrectly. I have a form used to submit copy requests. Occasionally we block dates for the copier's vacation. If a person types a date, such as 01/03/2020, then the form converts it to 1/3/2020. All fine and well, except, when that occurs, it doesn't spur the .change function in our JavaScript in Edge. Further, the script works as intended in Chrome.
Ultimately we are only trying to prevent a person from selecting blocked dates for a request, and in the event they try to type a blocked date, they get an error message. I am sure there are different validation methods to do this, but we like the script we have as it is easy to update. I am unsure if this was always a problem as there have always been full dates (as in 10-10-2019 or 11-12-2013).
Here is the script:
$(function() { $(document).ready(function () { var array = ['2020-01-03','2020-01-06']; // Four digit year function checkDate(date) { var string = jQuery.datepicker.formatDate('yy-mm-dd', date); return [ array.indexOf(string) == -1 ] } function checkField(input, inst) { if ($(input).closest('li').hasClass('dueDate')) { $(input).datepicker("option", {beforeShowDay: checkDate}); } } $.datepicker.setDefaults( {beforeShow: checkField} ); $('.dueDate input').on('change', function(event) { var value = event.currentTarget.value; if (value == '1/3/2020' || value == '1/6/2020'){ alert( "I will not be available this day, please select another Due Date." ); event.currentTarget.value = ''; } });
Thanks in advance!