These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How do I do a length check on a numeric value?

sz4zkk
Registered: May 23 2007
Posts: 26

I have a Print button that has the following 'if' statement:

if (xfa.form.form1.EmployeeInfo.EmployeeID.rawValue.length > 6)

The code doesn't even execute.

I also tried the following to see if I could get a value (it does execute, but returns 0):

app.alert(xfa.form.form1.EmployeeInfo.EmployeeID.length)

How do I do a length check on a numeric value?

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
What happens when you use the "formattedValue"?

George Kaiser

sz4zkk
Registered: May 23 2007
Posts: 26
Cool. That worked great. I used the following:

if (xfa.form.form1.EmployeeInfo.EmployeeID.formattedValue.length > 6)Just for my information: Shouldn't one or both of the staements below given me the same result? I just curious why the statements below didn't work (My field is defined as a numeric field.):

if (xfa.form.form1.EmployeeInfo.EmployeeID.length > 6)or

if (xfa.form.form1.EmployeeInfo.EmployeeID.rawValue.length > 6)Thanks a Lot for your help. Been messin with this for more than a day. :)
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Computers can store numbers in many formats for and the length of the field varies by the format not the value of the stored value because of leading zeros. If you want the length of the stored value, one is always better off using the formatted string value without the leading zeros.

George Kaiser