简体   繁体   中英

Keeping leading zeros in Adobe Acrobat XI Pro

How do I retain a 0 in the numeric formatted fields when the zero is at the beginning of a number? right now the field drops the 0 and proceeds to display the second number. For example, in the number field, if i enter "00100", then it displays as "100".

I have written a keystroke script to accept only numbers but I need to limit the numbers to 6 digits

Please help.

function numOnly_ks() {

    // Get all of the characters that have been entered in to the field
    var value = AFMergeChange(event);

    // Do nothing if field is blank
    if(!value) return;

    // Reject the entry if the entry doesn't match the regular expression
    if(!AFExactMatch(/^[0-9 /+]+$/, value)) event.rc = false;

}

One possibility is to add this to the Validate event:

event.value = util.printf("%,106d", event.value) ;

Note: I have not tested it, but it should work. You might have a look at the util.printf() method description in the Acrobat JavaScript documentation.

Do you actually need the field entry to be a numerical value (ie, do you need to use the value for mathematical purposes)? If not, you can just set the field to be a text entry, which will allow a user to enter numbers as text in the field, and will thus allow the entry of leading zeros. To do this, go to the following menu: Edit>Edit Text & Images>Forms>Edit>[then click on the field you want to edit]>Edit Fields>Show Field Properties>Format>[then set "Select Field Properties" to "None"]. This change will allow a user to enter any characters in the field, so it's not going to be an option for any form owner/creator who needs to limit the field entry parameters/rules for users. But it works as a quick one-off solution to force leading zeros.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM