Copy link to clipboard
Copied
I am trying to create a fillable form using Acrobat Pro DC 2018 for Mac. One of the fields asks for the employee number. Some begin with zero, but after entering the number and saving the form, the leading zero doesn't show up.
Set the format to None.
Copy link to clipboard
Copied
Set the format to None.
Copy link to clipboard
Copied
Sir,
Setting the format to None, the field will also accept alphabets, and then it is not an 'only number' field. The leading zero has to be displayed in Number field alone. In some of the very earlier versions of Excel, it was easy to choose Number format to 'display' or 'do not display' leading zeros.
R G Kulkarni
Copy link to clipboard
Copied
PDF and Excel are very different things. If you want the field to only accept numbers, but still allow initial zeros, use the following code as its custom Keystroke script (under Properties - Format - Custom):
if (event.change) event.rc = /^\d+$/.test(event.change);
Note that using this code you won't be able to enter the negative symbol, or a comma, etc. Only digits.
Copy link to clipboard
Copied
Sir,
Greatly honoured to get so fast a reply. The code has worked and I am able
to get the leading zero being displayed in the 'Number' only field.
Thanks and regards,
Saibai40
[Private info removed]
Copy link to clipboard
Copied
Thank you for this!!
Copy link to clipboard
Copied
I have a field set up as a comb for the last four digits of social security numbers and have the same problem with Adobe truncating leading zeros. I tried this code and, while it kept the leading zero (yay!) it also allowed letters to be entered, instead of only allowing numbers. Isn't it possible to have a field only accept numbers AND keep leading zeros? I am NOT a programmer, so I need something very simple.
Copy link to clipboard
Copied
The code I posted above will only allow numbers to be entered into the field. Are you sure you used it as described in my original post?
Copy link to clipboard
Copied
I copy/pasted directly from your post, but I figured out an easier way to do it that doesn't involve programming. I selected Format / Special / Arbitrary Mask and entered 9999
That did it!
Copy link to clipboard
Copied
That works too, but only if the value has a fixed length.
Copy link to clipboard
Copied
This field is a fixed length so I am set (at least for this form). 🙂
Copy link to clipboard
Copied
God bless you, this scripts worked perfectly
Copy link to clipboard
Copied
I have tried this, and while it does keep the leading 0, it allows letters as well, not just numbers. I see this answer is a few years old - is there an updated formula to use?
Copy link to clipboard
Copied
I found another page that specified to enter this in the Custom Keystone Script area, notthe Custom Format Script area; I didn't see that specified here. Changing the field worked!
Copy link to clipboard
Copied
I am very new to applying script to Adobe Acrobat Pro 2017 PDF forms. I have a form where I concatnate two fields (WBSProgram & WBSJobcode) into a third (labeled CompleteWBS) for Work Breakdown Structure (WBS) cost accounting codes. A WBS is alphanumeric, can start with a 0 that must be displayed in the final field.
My problem is my final field (CompleteWBS) does not show the 0 in the WBS if it starts with a 0.
this is a correct WBS
RA.02148956.0123456
my current field would populate this
RA.2148956.23456
Is there a script I can apply to still allow letters and also keep leading 0?
Copy link to clipboard
Copied
Correction, There are three fields that concatnate into the fourth CompleteWBS. The first is the WBSType
in the above WBS example, the RA is the WBSType
Copy link to clipboard
Copied
What script does you use?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Your code is difficult to read.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Use a external Javascript editor like notepad++.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
thank you
Copy link to clipboard
Copied
Thanks ever so much!!! That worked.