Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you get the zero to stay in a field after you click out of it.

New Here ,
May 12, 2017 May 12, 2017

If my user enters a number that starts with zero, the zero disappears once they click out of the field.  I need for the zero  to stay.  For example, they enter 09876, only 9876 shows

This is the script that I have so far in it.

.

var desiredLength = 9; // the number of digits the user should enter

event.rc = true;
if (event.value && event.value.length!=desiredLength) {
    app.alert("You must enter exactly " + desiredLength + " digits.");
    event.rc = false;
}

TOPICS
Acrobat SDK and JavaScript
313
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2017 Jun 29, 2017
LATEST

The over whelming number of programs and applications do not show leading zeros. Leading zeros are generally associated with character strings and need special formatting.

Working within a field, the event.value will retain the leading zeros. To read the value of a different field you need to use the valueAsString method. One can force the value to have leading zeros by using the util.printf method. You should be aware that the format for a field only affects the displayed value and not the actual value of the field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines