Check to see if any date field is less than the last day of the month
I have a form with expiration dates of about 30 medications. Is it possible in java script to check all date fields on a given page and alert the user prior to submission of the form that a medication is going to expire before the end of the month?
var expirationDates = [new Date("2022-01-01"), new Date("2021-04-16")]; // your dates
var date = new Date(), y = date.getFullYear(), m = date.getMonth();
var lastDay = new Date(y, m + 1, 0);
for (i = 0; i < expirationDates.length; i++) {
if (expirationDates[i] < lastDay){
alert('about to get expired!');
}
}