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

Discussion

Discussion

Feature Request: Forms Date Picker - Date Limit

posted on September 26, 2019

Hi all,

Would it be possible to add an optional limit/constraint to the forms date picker which prevents users from selecting certain dates from the calendar? I'm aware you can limit the year, but we have come accross a few scenarios now where clients have asked us to only allow dates before/after the current date (e.g. for a date of birth field, you shouldn't be able to select dates in the future).

I've read here that this is possible with some coding, but it would be a good option to have out of the box if possible!

Many thanks,

Dan

3 0
replied on September 27, 2019

Out of the box would be nice. If you want to limit to dates after the current date, you can do something like below. Obviously you would have to change #Field3 for your Form.

$(document).read(function(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; 

var yyyy = today.getFullYear();
if(dd<10){
    dd='0'+dd;
} 
if(mm<10){
    mm='0'+mm;
} 
var today = yyyy+'-'+mm+'-'+dd;
$('#Field3').attr('min',today);
});

 

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

Sign in to reply to this post.