You are viewing limited content. For full access, please sign in.

Question

Question

Rules in Date fields

asked on April 24, 2017

Hello everyone,

how can i set rules to date fields? For example, Birth date should be under the current date.

 

Regards,

-Guillaume

0 0

Replies

replied on April 25, 2017

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

2 0
replied on April 24, 2017

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

0 0
replied on April 25, 2017

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

 

0 0
replied on April 28, 2017 Show version history

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...

0 0
replied on April 28, 2017 Show version history

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:

0 0
replied on September 5, 2018

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!

0 0
replied on September 5, 2018

This seemed to simple to work ( I don't really know how this all works) but it appears to work. 

 

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.