简体   繁体   English

在 Adob​​e Acrobat XI Pro 中保留前导零

[英]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?当零位于数字开头时,如何在数字格式字段中保留 0? right now the field drops the 0 and proceeds to display the second number.现在该字段删除 0 并继续显示第二个数字。 For example, in the number field, if i enter "00100", then it displays as "100".例如,在数字字段中,如果我输入“00100”,则显示为“100”。

I have written a keystroke script to accept only numbers but I need to limit the numbers to 6 digits我编写了一个按键脚本来只接受数字,但我需要将数字限制为 6 位

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:一种可能性是将其添加到 Validate 事件中:

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.您可以查看 Acrobat JavaScript 文档中的 util.printf() 方法描述。

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.但它可以作为强制前导零的快速一次性解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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