Warning Pop up message based on date calculation/validation?

New Here ,
Oct 04, 2018

Copy link to clipboard

Copied

I need some help to see if its even possible for a message to display if I person enters a date, that is less than 2 days from today.  The message would just be a read only pop up that warns the form completer that if their event is less than two days from now, they should call a specific person to arrange their reservation space.  I tried some options in LiveCycle but I think LiveCycle is a little more complicated for me and the date field threw the message no matter what date was entered.  So now I am using Acrobat Pro DC.  And the field is currently a date field m/dd/yy format.  No other validation or calculations currently set on the field.

I'm not a coder, so I may just be overthinking it or the script I'm looking for isn't a scripting thing at all but some other option I'm not aware of.  I don't want it to stop the user from entering the date, but prompt them to call ahead because of short notice. (our organization has approval processes in place for these things and sometimes its can take a whole other day for the approved form to get to the meeting reservations/setup crew)

Thoughts? Help? Pretty please?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this code as the custom validation script of your text field:

if (event.value) {

    var msPerDay = 86400000;

    var today = new Date();

    var d = util.scand("m/dd/yy", event.value);

    if ((d.getTime()-today.getTime())<(2*msPerDay)) {

        app.alert("Enter your message here.",1);

    }  

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

95

Likes

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

Warning Pop up message based on date calculation/validation?

New Here ,
Oct 04, 2018

Copy link to clipboard

Copied

I need some help to see if its even possible for a message to display if I person enters a date, that is less than 2 days from today.  The message would just be a read only pop up that warns the form completer that if their event is less than two days from now, they should call a specific person to arrange their reservation space.  I tried some options in LiveCycle but I think LiveCycle is a little more complicated for me and the date field threw the message no matter what date was entered.  So now I am using Acrobat Pro DC.  And the field is currently a date field m/dd/yy format.  No other validation or calculations currently set on the field.

I'm not a coder, so I may just be overthinking it or the script I'm looking for isn't a scripting thing at all but some other option I'm not aware of.  I don't want it to stop the user from entering the date, but prompt them to call ahead because of short notice. (our organization has approval processes in place for these things and sometimes its can take a whole other day for the approved form to get to the meeting reservations/setup crew)

Thoughts? Help? Pretty please?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this code as the custom validation script of your text field:

if (event.value) {

    var msPerDay = 86400000;

    var today = new Date();

    var d = util.scand("m/dd/yy", event.value);

    if ((d.getTime()-today.getTime())<(2*msPerDay)) {

        app.alert("Enter your message here.",1);

    }  

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

96

Likes

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
Oct 04, 2018 0
Most Valuable Participant ,
Oct 04, 2018

Copy link to clipboard

Copied

Use this code as the custom validation script of your text field:

if (event.value) {

    var msPerDay = 86400000;

    var today = new Date();

    var d = util.scand("m/dd/yy", event.value);

    if ((d.getTime()-today.getTime())<(2*msPerDay)) {

        app.alert("Enter your message here.",1);

    }  

}

Likes

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
Reply
Loading...
Oct 04, 2018 1
New Here ,
Oct 04, 2018

Copy link to clipboard

Copied

Perfect, thanks so much!

Likes

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
Reply
Loading...
Oct 04, 2018 0