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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Select present and future dates only

GRodLegacy
Level 2
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.

date date and time field date drop down date picker date range
1 Accepted Solution
santhosh_kumark
Correct answer by
Community Advisor
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

18 Replies
Mayank_Gandhi
Community Advisor
Community Advisor

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

Mayank_Gandhi
Community Advisor
Community 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.
Mayank_Gandhi
Community Advisor
Community Advisor
@GRodLegacy I will create one and share it with you in a little while.
Mayank_Gandhi
Community Advisor
Community 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); }
GRodLegacy
Level 2
Level 2
@Mayank_Gandhi I have tried it on exit and change events and I'm not seeing anything
Mayank_Gandhi
Community Advisor
Community 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
GRodLegacy
Level 2
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
Mayank_Gandhi
Community Advisor
Community Advisor
@GRodLegacy Send me your email in pvt message I will mail you the sample.
Mayank_Gandhi
Community Advisor
Community 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);
}

santhosh_kumark
Correct answer by
Community Advisor
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