-
1. Re: displaying a message based on age
MichaelN Aug 21, 2013 3:40 PM (in response to JimBobVBA)Have a look at this thread for calculating a person's age:
http://forums.adobe.com/message/5507632#5507632
The script can be modified at the end to include something like:
if (age > 18){
//do something
}
else
//do something else
That should get you started.
I hope this helps.
-
2. Re: displaying a message based on age
JimBobVBA Aug 22, 2013 7:34 AM (in response to MichaelN)Have a small problem. The code works fine as a calculation and pops the correct message. However, the same message pops up when data is entered on other date fields that do not have calculations – any thoughts
-
3. Re: displaying a message based on age
GKaiseril Aug 22, 2013 7:39 AM (in response to JimBobVBA)Do all the date fields have the same name?
Where are you placing your scirpt?
Do you understand the event processing within a PDF form?
-
4. Re: displaying a message based on age
JimBobVBA Aug 22, 2013 9:18 AM (in response to GKaiseril)Have only one field on the entire form that calculates age and based on that age pops a message. This is written as a custom calculation script on Child1DOB. Once the message appears once, it continues to appear when I exit any other field. Check and double checked set-up. Appear to be missing something.
var dobValue = getField("Child1DOB").value;
if (dobValue!="") {
var dob = util.scand("mm/dd/yyyy", dobValue);
var today = new Date();
var age = today.getFullYear() - dob.getFullYear() - 1;
if (today.getMonth()>dob.getMonth()) {
age++;
} else if (today.getMonth()==dob.getMonth()) {
if (today.getDate()>dob.getDate())
age++;
}
event.value = age;
if (age>18)
{
app.alert("This dependent is over the age of 18. Based on your group's eligiblity rules for dependent children, you may need to provide further information in the Special Dependent Information Section below. This section will allow you to designate Full Time Student or Handicapped status.", 1, 0);
event.rc = false;
}
-
5. Re: displaying a message based on age
GKaiseril Aug 22, 2013 9:57 AM (in response to JimBobVBA)The calculation events are executed when any field is updated just in case a field update changes the result of the calculation in another field.
You need to work out where to put your code or only run it once.
-
6. Re: displaying a message based on age
JimBobVBA Aug 22, 2013 10:44 AM (in response to GKaiseril)Thanks for the update. New to custom calculation. How do I force it to only run once and on the specific field. Thanks!!
-
7. Re: displaying a message based on age
GKaiseril Aug 22, 2013 11:12 AM (in response to JimBobVBA)I would use the "Validation" tab to enter a custom Validation script. This script only runs when the field's value changes.



