in the date field, it starts from today until 10 days later. and all other dates cannot be selected and are turned grey.
if this cannot be done, is there a validation method to check the 10days requirement?
thanks!
Views
Replies
Total Likes
Hi,
You can not limit the days that can be selected in the standard date picker, so you will need to validate what they have entered. Something like;
if (this.formattedValue === this.rawValue) // Date format not recognised
{
app.alert("Please enter a valid date");
}
else
{
var DateRegex = /(\d\d\d\d)-(\d\d)-(\d\d)/;
var d = DateRegex.exec(this.rawValue);
if (d !== null)
{
thisDate = new Date(d[1], d[2]-1, d[3]);
var today = new Date(new Date(Date.now()).setHours(0,0,0,0)); // Time at start of day
if (thisDate < today)
{
app.alert("The date can not be before today");
}
else
{
var todayPlus10Days = new Date(today.setDate(today.getDate() + 10));
if (thisDate > todayPlus10Days)
{
app.alert("The date can not be more than 10 days in the future");
}
}
}
}
Regards
Bruce
Views
Replies
Total Likes
Thank you Bruce. the time validation is helpful!
Views
Replies
Total Likes