Copy link to clipboard
Copied
Is there a custom validation script that will only allow 6 decimal places to show and not round if more are entered?
Copy link to clipboard
Copied
Yes, use this:
var num = event.value;
var dec = num.match(/^-?\d+(?:\.\d{0,6})?/)[0];
event.value = dec;
Copy link to clipboard
Copied
Hi Nesa,
I apprecaite the response! The script works, however when testing I found that when entering a value without a number to the left of the decimal and entering more than six decimal places, the value will round (i.e. .1234567 will round to .123457 vs 0.1234567 will round to 0.123456).
Thank you in advance for the help!
Copy link to clipboard
Copied
Code is working as intended, if you enter .1234567 code won't work at all, so I don't know how you got it to round it to .123457?
You need to be specific when you asking for help, so you will entering numbers as .1234567 do you want result to be .123456 or 0.123456?
Copy link to clipboard
Copied
If possible when entering .1234567 I would want the result to be 0.123456
Copy link to clipboard
Copied
To clarify, I want the original script to work as intended and have .1234567 to round to 0.123456.
Copy link to clipboard
Copied
You should use this AFNumber_Format:
if (event.value && !isNaN(Number(event.value))) {AFNumber_Format(6, 0, 0, 0, "", false);}
The Acrobat provided forms function call:
AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend)
nDec = number of decimalssepStyle = separator style 0 = 1,234.56 / 1 = 1234.56 / 2 = 1.234,56 / 3 = 1234,56 /negStyle = 0 black minus / 1 red minus / 2 parens black / 3 parens red /currStyle = reservedstrCurrency = string of currency to displaybCurrencyPrepend = true = pre pend / false = post pend
Copy link to clipboard
Copied
That is not going to work, firstly it will round number which OP said he doesn't want, secondly once entered it won't work anymore because decimal point is removed.
Copy link to clipboard
Copied
Oops!
I read too fast.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now