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

How to set date conditions on PDF?

Explorer ,
Jul 23, 2024 Jul 23, 2024

Hello,

I need to set date conditions so that when a student enters a date into the ORIGINAL EXAM DATE field, it is BEFORE today; and when a student enters a date into the PROPOSED EXAM DATE field, it is AFTER today.

 

Thank you!

TOPICS
How to , JavaScript , PDF , PDF forms
424
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Assuming the date fields are formatted as mm/dd/yyyy, enter the following custom validation script into the Original Exam Date field:

if(event.value && util.scand("mm/dd/yyyy", event.value)> new Date())
{
app.alert("Date must be before today.",1)
event.value="";
}

 

Enter the following custom validation script into the proposed exam date:

if(event.value && util.scand("mm/dd/yyyy", event.value)<= new Date())
{
app.alert("Date must be after today.",1)
event.value="";
}

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
Community Expert ,
Jul 24, 2024 Jul 24, 2024
LATEST

To reject the entered value it's better to use:

event.rc = false;

Instead of:

event.value="";

The former will revert the field to its previous value, instead of clearing it altogether.

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
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Assuming the date fields are formatted as mm/dd/yyyy, enter the following custom validation script into the Original Exam Date field:

if(event.value && util.scand("mm/dd/yyyy", event.value)> new Date())
{
app.alert("Date must be before today.",1)
event.value="";
}

 

Enter the following custom validation script into the proposed exam date:

if(event.value && util.scand("mm/dd/yyyy", event.value)<= new Date())
{
app.alert("Date must be after today.",1)
event.value="";
}

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 ,
Jul 24, 2024 Jul 24, 2024
LATEST

To reject the entered value it's better to use:

event.rc = false;

Instead of:

event.value="";

The former will revert the field to its previous value, instead of clearing it altogether.

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