In my form, I use a date field which is configured as a default value of 'Today' so the users do not have to click on the calendar icon and select the current date. Works great.
Now, I wanted to have a field below it displaying the day of the week. I found code on a posting from this site that does that.
My issue is this. The code only executes when the user enters a date by either typing one in or clicking the date calendar icon. The date is already in that field upon page load because Forms is configured to use the default of Today.
I would like to know if the code can be changed so that it recognizes a date is already in the field and thus displays the day of the week.
$(document).ready(function () {
function findDay() {
var d = new Date($('#Field79').val());
var weekday = new Array(7);
weekday[0]= "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
$('.dayWeek select').val(n);
$('.dayWeek select').trigger('change');
}
$('.WORK').on('change', 'input', findDay);
});