Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

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!

3 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