I have a Date Picker ( #datePicker1 ) on a page, where the user chooses a “Check-In Date”.
And I have a Button ( #button10 ) - which needs to be HIDDEN / SHOWN based on the date ‘PICKED’ in the date-picker field.
If the user chooses a date between 1st April and 31st August - the BUTTON should be VISIBLE - Otherwise, it should be hidden.
I have managed to get it to work more or less as it should - but the ‘solution’ is restricted to the CURRENT YEAR…
Here’s my code ~
export function datePicker1_change(event) {
var startD = new Date('04/01/2021');
var endD = new Date('08/31/2021');
var CheckIn = $w('#datePicker1').value;
if(startD >= CheckIn || endD <= CheckIn) {
$w('#button10').hide()
} else {
$w('#button10').show()
}
}
NEED HELP WITH THE FOLLOWING ~
-
Change the code so that it works for ANY YEAR in the future
[i.e. not have it specify ‘2021’ in the ‘new Date()’ parts of the code] -
Make the code such that the ‘new Date()’ variables are BASED ON OUR LOCAL TIME (Indian Standard Time - IST) - and not affected by the Users local time (eg. a user in the US/UK)
Thanks in advance, for any help…
(NB: I am a novice at coding - so, do bear with my ignorance!)