I'm using Livecycle Designer ES2 provided with Acrobat X Pro.
I have a form where the age field is calculated from the date of birth field. The date of birth field (DOB) is a date/time field. The age field (Age) is a numeric field.
Problem is: when user enters 01/01/01 shows age as 101. When user enters 01/01/2001 age shows 1. All patterns are set to mm/dd/yyyy. Is there a way to prohibit the user from continuing to the next field until the proper format is entered? I'm open to any ideas which will acheive the desrired outcome. I'm new to livecycle and javascript. I suspect an easy solution but I can't seem to find it when searching the forums or LD help menu.
I've attached the script for the Age field in case it helps.
Age::calculate - (JavaScript, client)
var ageInYears = 0;
var birthDate = new Date();
if ( DOB.rawValue != null )
{
// Get current date, and convert user-entered date to a Date object.
var curDate = new Date();
birthDate.setTime(Date.parse(DOB.editValue));
// Set initial age, current year - birth year
ageInYears = curDate.getFullYear() - birthDate.getFullYear();
// If we haven't reached the birth month yet, not yet 1 year older...
if ( curDate.getMonth() < birthDate.getMonth() )
ageInYears--;
// If this month is same as birth month but we haven't reached the
// birth date yet, not yet 1 year older...
if ( curDate.getMonth() == birthDate.getMonth() )
if ( curDate.getDate() < birthDate.getDate() )
ageInYears--;
// Set age in result field.
this.rawValue = ageInYears;
}
Solved! Go to Solution.
Views
Replies
Total Likes
In the exit event of the date of birth box put (in formcalc):
if (Date2Num($.formattedValue, "MM/DD/YYYY") == 0) then
$=""
endif
and then under Object>Value just make sure you put a message into the 'Validation Pattern Message' saying something like: 'Please enter the date in the format MM/DD/YYYY'.
Views
Replies
Total Likes
In the exit event of the date of birth box put (in formcalc):
if (Date2Num($.formattedValue, "MM/DD/YYYY") == 0) then
$=""
endif
and then under Object>Value just make sure you put a message into the 'Validation Pattern Message' saying something like: 'Please enter the date in the format MM/DD/YYYY'.
Views
Replies
Total Likes
Hi,
I would not force the user tio enter date in a specific format, this is often frustrating.
Better is to allow multiple ways of entering a date, which then is formatted in the desired format.
This is easy with using display and edit patterns.
Views
Replies
Total Likes
Radzmar,
Thanks for the great advice at: http://thelivecycle.blogspot.de/2011/10/date-patterns.html
However I can't get this method to work. I would like the date to display as MM-DD-YYYY regardless of what the user enters. 2 problems show up. First I get this annoying dialog box
and then second the date box doesn't even display the date in the MM-DD-YYYY format I would like. For instance if I enter 10/15/1994 the dialogue box above appears but doesn't display 10-15-1994, it just displays it as 10/15/1994. There seems to be a difference between pressing enter or return on keyboard after typing the date, versus just clicking out of the date box. I can't get a sample date in the "Sample" line like you had. Any ideas?
Views
Replies
Total Likes
I have nearly the same issue. I just want a MONTH YEAR the user can enter or pick from a drop down. I can get this to work until I meet the all caps requirement then its validation errors....
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies