How to display age as years, months and days?

leighh77457178

10-10-2018

Hi

I have a form created in livecycle designer and one of the fields is age at diagnosis - I want to format the field to allow the user to enter the age the person was at diagnosis manually (its not calculated from date of birth (DOB) or from any other date its just an age that the  person completing the form would know). If I want to manually add this to a field how can I format it so that the user enters the age in years months and days? Currently we are experiencing a few problems as some people are using the field to enter the age in months and then some are entering the age in years so its a bit confusing when trying to analyse this data.

I want to make it as easy as possible to enter the age in the format I want i.e. years months and days.

thanks in advance!

View Entire Topic

mouslander

10-10-2018

I played with the regular expression. It is not perfect but should provide help:

var myRegExp = /[0-1][0-9]+Y [0-1][0-9]+M [0-3][0-9]+D/;      // Created a regular expression. This will only allow 2 digits for the year with                                                                                                 // the "Y" for year, 2 for month with an "M" 2 for days with a "D". This does not                                                                                                 // restrict an incorrect entry for example if the user puts in 14 months it will                                                                                                 //allow it.

var myText = ExecFromDate.rawValue;

if(ExecFromDate.rawValue == null){

ExecFromDate.rawValue = null;

}

else

if(myRegExp.test(myText)== false){

xfa.host.messageBox("You have entered an incorrect Years Months and Days format. Please see sample: 12Y 11M 09D", "Date error", 3, 0);

xfa.host.setFocus("ExecFromDate")

ExecFromDate.rawValue = "false"

}