Dear,
I have a form with a datePicker.
Here my JS:
$( "#"+from ).datepicker({
changeMonth: true,
changeYear: true,
minDate: new Date(2018, 09 - 1, 15),...
This works and my datepicker minimum date is set to the desired date. However, This date can be variable so I saved it in [types field='first-day-of-semester' style='text' format='F j, Y' id="643"][/types] (as global variable), but could not set mindate to this value of type field.
I tried with a generic field in my form:
first day:[cred_generic_field field='firstday' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"1537128000000"
}
[/cred_generic_field]
My idea was to put [types field='first-day-of-semester' style='text' format='F j, Y' id="643"][/types] as default value of the generic field and then use this generic field default value in my JS to set minDate, but could not. Any clue please?
Thank you Shane,
Actually my final aim is to set minDate of datepicker to
[types field='first-day-of-semester' style='text' format='F j, Y' id='643'][/types]
The generic field was a turnaround.
Dear Shane
Yes the field is to determine the semester start. Instead of using a direct value in datepicker such us:
Mindate: new Date (2018, 9 -1, 1),
I need to get the date from the user (using another form) and then populate the mindate of datepicker.
So it sould be something like:
Mindate: new Date (x)
Where x is the value of [types field='first-day-of-semester' style='text' format='F j, Y' id='643'][/types]
Thank you for your help
So here is what I understood from your previous message.
"I need to get the date from the user (using another form) and then populate the mindate of datepicker."
I'm unclear here but i'm assuming that there is a fixed date somewhere and you don't want the user to select a date below that minimum date that is set somewhere else.
Hi
Yes, the admin will select the min date n another form. This date is stored in [types field='first-day-of-semester' style='text' format='F j, Y' id='643'][/types]. Now when the customer wants to select a date, the min date should be the one stored by the admin.
What you can do as I just thought of this is to print the field value [types field='first-day-of-semester' style='text' format='F j, Y' id='643'][/types] in a tag somewhere on the page.
Then using jquery, get this value then you should be able to convert this date to an actual date in jquery using your code and set the min value to that date.