How to restrict Date fields to allow selection for future dates alone?

cancel
Showing results for 
Search instead for 
Did you mean: 
paiyyavj13
Established Member II

How to restrict Date fields to allow selection for future dates alone?

Jump to solution

Hi,

I am using APS 1.6.4, In the Form fields when I use a Date field- there is a Min and Max Value available in the Advanced tab of the Date field in the Form editor.

How can I restrict selection to be future dates? Does the above fields help me in this regard?

Any suggestions would be appreciated... Thank you...

Regards.

1 Solution

Accepted Solutions
amruta_w
Senior Member

Re: How to restrict Date fields to allow selection for future dates alone?

Jump to solution

Using javaScript you can do.

Create two date field then in javascript write

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var todaysdate=dd+"-"+mm+"-"+yyyy;
form.fields[0].fields[1][0].maxValue=todaysdate;
form.fields[0].fields[2][0].minValue=todaysdate;

View solution in original post

3 Replies
amruta_w
Senior Member

Re: How to restrict Date fields to allow selection for future dates alone?

Jump to solution

Using javaScript you can do.

Create two date field then in javascript write

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var todaysdate=dd+"-"+mm+"-"+yyyy;
form.fields[0].fields[1][0].maxValue=todaysdate;
form.fields[0].fields[2][0].minValue=todaysdate;

paiyyavj13
Established Member II

Re: How to restrict Date fields to allow selection for future dates alone?

Jump to solution

‌ Hi- I need to get the date field from the form object- In the example given by you we assume that the first field in the form is the date field- I was checking the api's but could not find anything useful-

For e.g.: if the form field id was "golivedate"- how would I get it from the form object? could you guide me? Thanks in advance...

amruta_w
Senior Member

Re: How to restrict Date fields to allow selection for future dates alone?

Jump to solution

you can changes this according to your requirement like

form.fields[0].fields[1][0].maxValue=todaysdate;  to form.fields[0].fields[2][1].maxValue=todaysdate

It is just an example.