Copy link to clipboard
Copied
Hey thanks for reading.
I've tried two reg expressions to find an 8 character numeric entry. Despite working on regexr, neither work in acrobat if the entry starts with 0.
^\d{8}$
or
Copy link to clipboard
Copied
My guess is you're using it on the value of a field, and you're accessing it with the value property. Is that correct?
If not, please post your full code, as this reg-exp shouldn't fail on a number that starts with a zero.
Copy link to clipboard
Copied
Are you testing the RegExp on a number? Regular expressions only work on strings, so any numbers are converted to strings first. The number 0123 converts to the string 123 or 123.000000 if you're not careful.
Try the RegExp on "01234567". It'll work just fine.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
My guess is you're using it on the value of a field, and you're accessing it with the value property. Is that correct?
If not, please post your full code, as this reg-exp shouldn't fail on a number that starts with a zero.
Copy link to clipboard
Copied
Indeed, I was using it on the value. Switching to valueAsString fixed the problem. When the number is converted to a string, it dropped the initial '0' digit, thus the remaining 7digit number failed.

