I am very new to forms but need to use Javascript to modify two calendar default dates to show as (1) labeled 'date from' to initially select a date 30 days from current and (2) labeled 'date to' as 3 days from 'date from.'
Any suggestions?
I am very new to forms but need to use Javascript to modify two calendar default dates to show as (1) labeled 'date from' to initially select a date 30 days from current and (2) labeled 'date to' as 3 days from 'date from.'
Any suggestions?
there are some modifications to the codes from other answers that can help you. Particularly, I remember a script that helped ensure 30 days between the first date and second date. I am sure someone will chime in with how to take that and make it do what you wanted.
For clarification, you want the user to be able to select the second date within 3 days of the first date, or it be automatically 3 days after the first date?
Automatically be three days, but allow user option to extend further.
Setting the first date to be 1 month from current - using links you provided - is inputting correct date, but in unrecognized format.
$(function() {
$(document).ready(function () {
var currentDate = $('.currentDate input').val(); // Gets Current Date Information from Hidden Field
var dateSplit = [];
dateSplit = currentDate.split("/");
var newMonth = parseInt(dateSplit[0]) + 1; // Get Month + 1
var AddYear = 0; // Year Offset
if (newMonth > 12){ // Determine if not a valid month
newMonth -= 12; // Make newMonth valid
AddYear = 1; // Increment year offset
}
var newYear = parseInt(dateSplit[2]) + AddYear; // Calculate the Year
var maxDate = (newYear+"-"+newMonth+"-"+dateSplit[1]);
$('.DateFrom input').val(maxDate); // Input current +1 month
});
});