asked on August 23, 2017
•
Show version history
I have a Form that requires a staff member to select the Month and Year that they want their Payslip from. The day, however, must be the 15th. I have some Javascript that changes the Day to the 15th.
However, it only seems to work if the day selected is greater than the 12th.
$(function() {
$(document).ready(function () {
$('.15Date input').on('change', function() {
var selectedDate = new Date($('.15Date input').val());
var year = selectedDate.getFullYear();
var month = ("0" + (selectedDate.getMonth() + 1)).slice(-2);
var newVal = '15/' + month + '/' + year;
$('.15Date input').val(month + '/15/' + '/' + year);
});
});
});
Any help will be appreciated
0
0