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

Date Validation

Guest
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

Hi All,

I have two date boxes on my PDF form. One start date and One end date. I need to validate the end date to ensure it is never more than One year after the start date.

For example.

Start date: 19/01/2017

End Date: 19/08/2017

^^^^ This is okay. However, If this happens;

Start date: 19/01/2017

End Date: 19/03/2018

^^^^ I would like an error message to pop up saying "End Date cannot be more than 12 months from the start date." and the box to be empty so the user can enter the correct date.

Does anybody if this is possible and if so, how do I do it?

Any help is appreciated.

Thanks

TOPICS
PDF forms

Views

4.8K

Translate

Translate

Report

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 ,
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

Hi Sam Orchard,

Did you try the Validate tab in the property dialog?

You can access the same by

1. Right clicking the desired field.

2. Click "Properties"

3. Go to "Validate" tab.

You can  perform the validation in this tab.You can run a custom validation script here to suit your needs.

You can also refer to the forum post for more details around the javascript validations   Date validation

Votes

Translate

Translate

Report

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
Guest
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

I know where the script would go, but I don't the script....

Votes

Translate

Translate

Report

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 ,
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

Have a look at the following forum post  Date validation

This may help you

Votes

Translate

Translate

Report

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
Guest
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

Not quite what I'm looking for....

Votes

Translate

Translate

Report

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
Guest
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

Hi.

Try this JavaScript as a Validation script in the end date field:

var startDat = new Date(this.getField("start").value);

var endDat = new Date(event.target.value);

var nStartDat = startDat.getTime();

var nEndDat = endDat.getTime();

var nMilliResult = (nEndDat - nStartDat) * 1;

if (nMilliResult > 31556952000) {

    app.alert("End Date cannot be more than 12 months from the start date.");

    event.rc = false;

} else {

    console.clear();

    console.show();

    console.println("Difference is less than a year");

}

You should remove the else statement after testing.

Votes

Translate

Translate

Report

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
Guest
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

Hi JR_Bouley,

Almost perfect!!! The only issue is the app.alert only pops up if they clear the end date date field then tab.

I need it to pop up as soon as they enter the wrong date and try to tab out.... so basically it's impossible to put a date in 12 months after the "Start_Date".

As the image below, it shouldn't let me tab out of the completion date if i've entered 25/03/2018.

Capture.PNG

Thanks for your help.

Cheers,

Sam

Votes

Translate

Translate

Report

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
Guest
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

LATEST

Capture2.PNG

Votes

Translate

Translate

Report

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