Copy link to clipboard
Copied
Hi,
I have manged to find a javascript that does the date calculation which worked with the date typed as 29/12/1961, now the customer want the date just typed as 29121961 in a text filed set to comb 8 characters now the calculation doesn't work, I've tried removing the / from this line of the javascript
dob = util.scand("dd/mm/yyyy", dobValue); but still no luck.
I've attached 2 test PDFs number 1 works ok number 2 doesn't, and also the working javascript below.
Unfortunately I do not have the skill to work this out and hopefully someone else will if at all possible
Thanks in advance
Paul
Javascript used below
dobValue = getField("DOB").value; if (dobValue!="") { dob = util.scand("dd/mm/yyyy", dobValue); var nTimeDiff = (new Date()).getTime() - dob.getTime(); var nYears = nTimeDiff/(365*24*60*60*1000); event.value = nYears; }
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Change the first line to:
var dobValue = getField("DOB").valueAsString;
Copy link to clipboard
Copied
Use:
util.scand("ddmmyyyy", dobValue)
Copy link to clipboard
Copied
Hi,
Thank for the reply, I've tried this and it just errors
thanks
Copy link to clipboard
Copied
What does the error message say?
Copy link to clipboard
Copied
I just get the javascript debugger console with all these errors
TypeError: this.getField(...) is null 1:Field:Format TypeError: this.getField(...) is null 1:AcroForm:Date of Birth:Format TypeError: this.getField(...) is null 24:Document-Level:Age TypeError: this.getField(...) is null 24:Document-Level:Age TypeError: this.getField(...) is null 24:Document-Level:Age TypeError: this.getField(...) is null 1:AcroForm:Date:Format TypeError: dob is null 9:Field:Calculate TypeError: dob is null 9:AcroForm:Age:Calculate TypeError: dob is null 9:Field:Calculate TypeError: dob is null 9:AcroForm:Age:Calculate TypeError: dob is null 9:Field:Calculate TypeError: dob is null 9:Field:Calculate TypeError: dob is null 9:Field:Calculate
Copy link to clipboard
Copied
Post your full code, please, or the file itself.
Copy link to clipboard
Copied
Hi sorry for the delay in replying, here is the file that is erroring I also tried Bernd Alheit suggestion but tat didn't seem to work either
Sorry the file is on a we transfer link below aas couldn't seem to attached to this list
Thanks all for your help
Copy link to clipboard
Copied
Change the first line to:
var dobValue = getField("DOB").valueAsString;
Copy link to clipboard
Copied
Thats brillant, working now.
Thank you all and have a great weekend
Copy link to clipboard
Copied
Use:
var dobValue = getField("DOB").valueAsString;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more