Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now