Copy link to clipboard
Copied
Hi, i have 9 date fields in "mm/yyyy" format. so i want Pick lowest Age. can u pls help me. thanks..
my form fields.
age of account1
age of account2
age of account3
age of account4
age of account5
age of account6
age of account7
age of account8
age of account9
See YoungestDateValues to see the results of 4 different ways to perform the task. Only 3 will provide the correct result.
Copy link to clipboard
Copied
What do you mean by "pick", exactly? Do you want to display the lowest age in a text field?
Copy link to clipboard
Copied
hi, yes i want to display the lowest age in a text field. thanks..
Copy link to clipboard
Copied
You can use this code as the custom calculation script of that field:
event.value = Math.min(Number(this.getField("age of account1").value), Number(this.getField("age of account2").value), Number(this.getField("age of account3").value), ...);
Copy link to clipboard
Copied
hi, bellow code is correct ?? it's giving some error..
value = Math.min(Number(this.getField("age of account1").value),Number(this.getField("age of account2").value),Number(this.getField("age of account3").value),Number(this.getField("age of account4").value),Number(this.getField("age of account5").value),Number(this.getField("age of account6").value),Number(this.getField("age of account7").value),Number(this.getField("age of account8").value),Number(this.getField("age of account9").value);
Copy link to clipboard
Copied
Why did you remove the "event." part at the start?
You're missing one closing parenthesis at the end.
Copy link to clipboard
Copied
ohh thanks. now code is working. i have add bellow 3 details but answer is "NaN"
02/2005
01/2000
07/2016
Copy link to clipboard
Copied
That's not an age, it's a date. If you want to compare dates it's more complicated.
Copy link to clipboard
Copied
The value you are trying find the youngest age is considered string type of variable. The minimum method requires numeric values. The "/" in the value makes it a string. You can either alphabetically sort the data or convert the dates to sequential numbers using the JavaScript Date object. Have you tried different entry values to see how the age field fills in?
Entering a value of "1/2000" will display as "01/2000" but have a value of "1/2000". This missing leading zero could cause a sort problem.
Copy link to clipboard
Copied
See YoungestDateValues to see the results of 4 different ways to perform the task. Only 3 will provide the correct result.
Copy link to clipboard
Copied
thanks a lot..
Find more inspiration, events, and resources on the new Adobe Community
Explore Now