Limitations on dates chosen in date input

Good morning,

Is it possible to programatorically put limitations on the date range that can be chosen on a date input (e.g. when the date for a meeting has to be set within three months from now, that the calender can be manipulated to only include the days between now and three months from now)?

Thanks!

Hi @Bart_Verhaeghe,

Not really.

You can however, make some logic code around it to let display a warning-tag for instance:

{% comment %}create variables and output them in seconds{% endcomment %}
{% assign date_gm = period.custom.date.gm | date:"%s" %}
{% assign date_now = "now" | date:"%s" %} 
{% comment %}create difference between two dates in seconds{% endcomment %}
{% assign diff_seconds = date_gm | minus:date_now %}
{% comment %}assign variable of seconds in 3 months{% endcomment %}
{% assign three_months_in_seconds = 7889231.49 %}

{% comment %}when more than 3 months ==> create warning tag{% endcomment %}
{% if three_months_in_seconds+0 <= diff_seconds+0 %}
  {% assign check_date = true %}
{% endif %}


{% stripnewlines %}
{% input period.custom.date.gm as:date %} 
{% if check_date %}
  {% ic %}
    {::warningtext}
      Date cannot be more than 3 months
    {:/warningtext}
  {% endic %}
{% endif %}  
{% endstripnewlines %} 

I think you get the idea: you calculate how many seconds there are between the two dates (of course, you can convert it into months for instance) with the %s method (which calculates any date into seconds from a fixed date in the past).

We use the same kind of logic in one of our standard legal templates of the special meeting by the way.