Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Select present and future dates only

Avatar

Level 2

Hello, I wanted to ask if there is a way to have someone only be able to select a date that is today or a later date but not past dates. Is this possible? Thank you in advance.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @GRodLegacy ,

 

If your requirement is to restrict the author to not select a past date then it could be achieved with the minDate property with value as "today". Or you can achieve it using Jquery:

$(function() {
$( "#datepicker" ).datepicker({ minDate: 0});
});

 

Regards,

SK

View solution in original post

1 Reply

Avatar

Employee Advisor

@GRodLegacy  What kind of form are you developing? Is it PDF or Adaptive form.

Avatar

Employee Advisor
@GRodLegacy We can prevent it at script level for sure. User will be able to see the date but if its not as per valid rule we can just ask him/her to reselect.

Avatar

Employee Advisor
@GRodLegacy Use this on date picker: var utc = new Date().toJSON().slice(0,10); if(this.value<utc){ alert("do not select previous dates"); this.value=null; guideBridge.setFocus(this); }

Avatar

Level 2
@Mayank_Gandhi I have tried it on exit and change events and I'm not seeing anything

Avatar

Employee Advisor
@ GRodLegacy https://drive.google.com/file/d/13jD2O6BwTyj9ara-EU0GUNAHap_IUsvf/view?usp=sharing once you select the date then you need to click somewhere outside or focus another field for value commit event to work

Avatar

Level 2
@Mayank_Gandhi I can't open the link because this is a work laptop. But I have added the script to the exit event and even after clicking on another field, it doesn't do anything

Avatar

Employee Advisor
@GRodLegacy Send me your email in pvt message I will mail you the sample.

Avatar

Employee Advisor

 

@GRodLegacy  Use this on date picker:

 

 

var utc = new Date().toJSON().slice(0,10);
if(this.value<utc){

alert("do not select previous dates");
this.value=null;
guideBridge.setFocus(this);
}

Avatar

Correct answer by
Community Advisor

Hi @GRodLegacy ,

 

If your requirement is to restrict the author to not select a past date then it could be achieved with the minDate property with value as "today". Or you can achieve it using Jquery:

$(function() {
$( "#datepicker" ).datepicker({ minDate: 0});
});

 

Regards,

SK