Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
8

Choose current and future dates only

New Here ,
Aug 10, 2023 Aug 10, 2023

Hello everyone, I'm very new to fillable forms and I hope you can help. I've been researching about this for awhile now to no avail. Please help 😅

 

I have a text field property that's formatted to Date. What I want to do is for the user to be able to choose present and future dates only when they click on it. Is that possible at all and can you share some workaround or there's really no solution for that? 

 

Most grateful for your responses. Thank you.

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
767
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Aug 10, 2023 Aug 10, 2023

You can try something like this as 'Validate' script of date field:

if(event.value){
 var currentDate = new Date();
 var enteredDate = util.scand("mm/dd/yyyy", event.value);

 currentDate.setHours(0, 0, 0, 0);
 enteredDate.setHours(0, 0, 0, 0);

 if(enteredDate < currentDate){
  app.alert("Please enter a current or future date.");
  event.value = "";}}

If the user doesn't enter a current or future date, it will pop alert and clear the field.

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 10, 2023 Aug 10, 2023

Hi there

Hope you are doing well and thanks for reaching out.

The workflow you are trying to achieve might be possible using JavaScript. For more information, please check the help pages listed below:
https://acrobatusers.com/tutorials/javascript_console/
https://helpx.adobe.com/acrobat/using/applying-actions-scripts-pdfs.html

Hope it will help

Regards
Amal

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2023 Aug 10, 2023

You can try something like this as 'Validate' script of date field:

if(event.value){
 var currentDate = new Date();
 var enteredDate = util.scand("mm/dd/yyyy", event.value);

 currentDate.setHours(0, 0, 0, 0);
 enteredDate.setHours(0, 0, 0, 0);

 if(enteredDate < currentDate){
  app.alert("Please enter a current or future date.");
  event.value = "";}}

If the user doesn't enter a current or future date, it will pop alert and clear the field.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 10, 2023 Aug 10, 2023
LATEST

OMG THANK YOU! It worked perfectly. I'm so grateful. Thank you so much Nesa!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines