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

Question

Question

Setting Minimum Date Value

asked on January 14, 2021

I am using below code in Forms 10.4.5 to set date field to not be able to select past 30 days. I get error 'Invalid Date' Has anything changed in 10.4.5 regards to this?

       var todaysDate = new Date();          
        var year = todaysDate.getFullYear();
        var month = ("0" + (todaysDate.getMonth() - 0)).slice(-2);
        var day = ("0" + (todaysDate.getDate())).slice(-2);  
        var minDate = (year + "-" + month + "-" + day);
        $('.effectiveDate input').attr('min', minDate);

0 0

Replies

replied on January 14, 2021 Show version history

There's an easier way to do this since the moment.js library is in Forms.

Here's the code I use, and it seems to be working fine in 10.4.5

This is setting the min date to "today" so you just need to adjust that to get your 30 day range.

// get date
var d = new Date();
  
// set minimum date
var minDate = moment(d,'MM/DD/YYYY').format('YYYY-MM-DD');
$('.effectiveDate input').attr('min',minDate);
1 0
replied on January 14, 2021

Thanks

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

Sign in to reply to this post.