Hi,
I have a date field into a collection. I added the following javascript :
//----------------------------------Date of Birth-------------------------------- var todaysDate = new Date(); // Gets today's date //Max date attribute is in "YYYY-MM-DD". Need to format today's date accordingly var dob_year = todaysDate.getFullYear()-18; //var dob_year = todaysDate.getFullYear(); // YYYY var dob_month = ("0" + (todaysDate.getMonth() + 1)).slice(-2); // MM var dob_day = ("0" + todaysDate.getDate()).slice(-2); // DD var dob_maxDate = (dob_year +"-"+ dob_month +"-"+ dob_day); // Results in "YYYY-MM-DD" for today's date // Now to set the max date value for the calendar to be today's date $('.dateofbirth input').attr('max',dob_maxDate);
I also added the class dateofbirth to the field.
This code add a restriction to the selection of dates. So people who have less than 18 years old cannot insert a date.
This work well on its on, but when the field is found into a collection, when i click on add, the code don't work on the replicated version of date field.
Please advise,
Best regards,
-Guillaume