Finding the length of a numeric field

Avatar

Avatar

janicer33771068

Avatar

janicer33771068

janicer33771068

12-11-2016

I'm new to Livecycle and need some help.  I have a numeric object and I want to make sure the user enters 10 numeric characters.  I want to check and make sure the records contains 10 numeric characters and if not, I want to display a message and set the focus back to the numeric object.  Problem is, I don't know how to write the code to check the length or which event to put the script.  I've tried several things with no success.  Any assistance would be greatly appreciated.

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar

Eric_Rosenfeld

Avatar

Eric_Rosenfeld

Eric_Rosenfeld

17-11-2016

1. Enter text{9999999999} into the Validation Pattern field (per real2's suggestion).

2. In the Object, Value tab, enter your message (i.e.- This field must contain exactly 10 numeric characters) in the "Validation Pattern Message" field and check the error box.

3. In the Object Value tab, select the "Form Level Validation Settings".  In "Form Validation", select "Color Failed Fields" and select a border color (red).  You can also select a background color, but the border color should be enough for your purposes.

As an option, you can also add a script in the exit event of the text field to erase the entry if less than 9 characters are entered:


if (this.rawValue.length < 10)


{


var vInput = TextField3.rawValue.toString();

this.rawValue = vInput.substring(0,10);


}

Cheers,

Eric

10 Characters.jpg

Avatar

Avatar

real2bman07

Avatar

real2bman07

real2bman07

15-11-2016

Hi,

I can only answer part one of your questions "I want to check and make sure the records contains 10 numeric characters and if not, I want to display a message and set the focus back to the numeric object."

So as shown below, under the field panel select the limit length in max chars field to 10

SOLUTION1.png

Am sure about the validation part but try playing with these below: The pattern button on the right has all sorts of validation just type in text{9999999999} in the sample or pattern fields and see what happens. As i said am not sure about this part. thanks

SOLUTION2.png