Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
September 26, 2016

Set the Format option to None and use this code as the custom validation script (you can also set the maximum number of characters to 6, if you wish):

event.rc = /^\d{0,6}$/.test(event.value);

6 replies

Participating Frequently
December 7, 2016

I need to have them enter an ID number between 5 and 7 digits long

- and I need to guarantee its numbers not letters

- and I need to allow leading zeros to display as well.

I currently have a format set to number and a validation script of:

---

var minLength = 5; // the minimum number of digits the user should enter

var maxLength = 7; // the maximum number of digits the user should enter

event.rc = true;

if (event.value && (event.value.length<minLength || event.value.length>maxLength))

{

   app.alert("You must enter between " + minLength + " and " + maxLength  + " digits.");

   event.rc = false;

}

---

This takes car of 5-7 digits and guarantees its a number but it still suppresses leading zeros in the display.

Any ideas?

Translate
try67
Community Expert
Community Expert
December 7, 2016

You can't use the Number format if you want leading zeros. Set it to None and replace your validation script with this:

if (event.value) {

    event.rc = /^\d{5,7}$/.test(event.value);

    if (!event.rc) app.alert("You must enter between 5 and 7 digits.");
}

Translate
Participating Frequently
December 8, 2016

That worked great thanks!

Where can I go to read up on what /^\d{5,7}$/ actually means?

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 26, 2016

Set the Format option to None and use this code as the custom validation script (you can also set the maximum number of characters to 6, if you wish):

event.rc = /^\d{0,6}$/.test(event.value);

Translate