Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Clear text data field if validation fails

Avatar

Level 1

Hello everyone,

I received some excellent help in regards to my previous post (Clear date field if validation fails) and liked how the form is working so I wanted to ask this similiar question.

I am using Livecycle 8.2.1 and have text fields set up with the edit and validation patterns as text{99999} and would like to clear those fields if the data entry is wrong.  What is happening is that if a user makes the wrong entry, the text remains in the text field.  The user can only enter five digits and if they don't do this the field should reset to blank.

I am a novice user.

Thank in advance!

0 Replies

Avatar

Level 5

Please give me more information. What should happens?

The user have to use 5 digits?

In which moment should the filed reset? When he enter only three digits? Or?

I think I can provide another solution for you.

Avatar

Level 1

Hello,

The user has to enter five numbers.  I would like the field to reset aftet the user exits the field or hits the enter key.  If the user does not put in five numbers then the field should reset to a blank field.

Avatar

Level 5

Hi,

please use this script in the exit-event of your textfield:

var nValueLength = this.rawValue;

if(nValueLength.length < 5)

{   

    xfa.host.messageBox("Please enter 5 digits.", "User Information", 1,0);

    this.rawValue = null;

}

Please set the following setting in object | field | limit length max chars 5.

If you need a script that allows only numbers in a textobject use the following in the change-event:

if(xfa.event.newText.match(/[^0-9]/))

{

    xfa.event.change = "";

}

That's all. Hope it will helps you,

Mandy