Hello everyone,
how can i set rules to date fields? For example, Birth date should be under the current date.
Regards,
-Guillaume
Hello everyone,
how can i set rules to date fields? For example, Birth date should be under the current date.
Regards,
-Guillaume
Guillaume,
Try setting the max date of the input field to the current date (today). It would end up looking like this:
This is the code I used, found here in Answers, to set the max date value of that field.
Might have to change the CSS class to your liking, but it works for me just fine. Hope this helps.
~Doug
Hi Guillaume,
If I understand you correctly, you can accomplish this by selecting the field on the Layout page of the form and clicking 'Edit'. At the bottom of the Edit dialog is a field named 'Default value'. One of the default values for is 'Current Date'. That should do it!
Thank you,
Rob
Hi Rob,
When Selecting Current Date, the current date is being displayed in the date of birth field.
What I need is to be able to select a date of birth which must be less than the actual date.(Date after the current date must be disabled).
Can you please advise?
Regards,
Guillaume
Guillaume,
The setting you are looking for is the second input of the "Year range" property:
Edit - Oh I see, this is only a year limitation, I can still select tomorrow...
Guillaume,
You can accomplish this using this Javascript. You'll need to replace #Field18 with the appropriate selector for your date field.
$(document).ready(function() { var today = new Date(); var mm = today.getMonth()+1; var dd = today.getDate(); var yyyy = today.getFullYear(); var todayString = yyyy + "-" + mm + "-" + dd; $('#Field18').prop('max', todayString); });
Now it looks like this:
Hello,
This works great, but I want to use it to restrict users under a certain age from entering their date of birth. In my case it is a volunteer form for a school district and we do not want applicants below age 11.
Is there a way to modify this code to subtract 11 years?
Thanks!
This seemed to simple to work ( I don't really know how this all works) but it appears to work.