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

How to reset the field after validation fails?

Avatar

Level 4

Hi

I have a date field which should be lesser than current date. I have used validation code in the validate event which returns either true or false and based on that error message gets displayed, which is all working fine.

Now if the validation fails, I want to reset the field which is not happenning in my case.

Pls. help.

Thanks

Abhiram

3 Replies

Avatar

Level 10

Hi,

You could include a line as part of the validation script:

this.rawValue = null; 

So that if validation fails, the message will display and then the field will be cleared.

Hope that works,

Niall

Avatar

Level 4

By doing so, the field is getting cleared but the message is not displaying.

Suppose lets take a case of email validation.

I have used the following code in the validate event

var

r = new RegExp();

r.compile("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$"

,"i");

var

result = r.test(this.rawValue);

if

(result == true)

{

true;

}

else

{

false;

}

In this code if i use this.rawValue=null after or before "false" ,error message is not getting displayed.

Thanks

Abhiram

PS: Validation part is working absolutely fine.

Avatar

Level 10

Hi,

I think the issue is that the value of the selection is not complete when you are validating, try the exit event. Also try resetting the date:

xfa.host.resetData("xfa.form.form1.page1.DateTimeField"); 

Hope that helps,

Niall