Expand my Community achievements bar.

SOLVED

Limit Number of Numbers Entered Into Integer Field In LiveCycle

Avatar

Level 3

Hi:

I have a numeric field on my form that I need to limit the number of numbers entered to 4 only.   The field can have leading zeros...  Is their someway to do this?

1 Accepted Solution

Avatar

Correct answer by
Level 10

I send you the code for NumericField only..

.length is a java script method which returns the length..

The error you got may be because you have not set your scripting language to Java Script and the code should be in Change event..

Attached is the sample..

https://acrobat.com/#d=4yJTgBa-x9Hn-bEbb0VV-w

Thanks

Srini

View solution in original post

4 Replies

Avatar

Level 10

The below code can check for the Field length and does not allow the user to enter more.

Place it in the Change event of the Numeric Field with java Script as language..

   

     //This is the length you want your NumericField to accept. If you want to add additional leading zeros then you need to set the length accordingly.

     var maxLength = 4;

     if(xfa.event.newText.length >maxLength)xfa.event.change = "";

Thanks

Srini

Avatar

Level 3

Thanks for the post...  However, .length was not a member of

newtext.  Also, the field is of type numeric ....  any other suggestions?

Avatar

Correct answer by
Level 10

I send you the code for NumericField only..

.length is a java script method which returns the length..

The error you got may be because you have not set your scripting language to Java Script and the code should be in Change event..

Attached is the sample..

https://acrobat.com/#d=4yJTgBa-x9Hn-bEbb0VV-w

Thanks

Srini

Avatar

Level 3

The code needs to go on the change event....  It worked like a champ at that point.