These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Validation - Clearing Textfield when Validation fails

EdwardKuk
Registered: May 14 2010
Posts: 26

Hi Everyone,

I am trying to erase the data in a textfield when validation fails. Currently, Validation works perfectly but after the message box, the incorrect data stays in the textfield, which defeats the entire purpose. I tried to use javascript to fix the issue with regular expressions but it doesnt seem to be working. The following is the code I am using.

phoneRegex = /^\(\d\d\d\) \d\d\d-\d\d\d\d$/;
if( phone.match( phoneRegex ) ) {
xfa.host.messageBox( "Please enter a valid phone number" );
this.rawValue = null;
}

If I can get any help, it will be greatly appreciated.

Thanks,
Edward Kuk

harry2ca
Registered: Jan 27 2010
Posts: 4
Try this:
phoneRegex = /^\(\d\d\d\) \d\d\d-\d\d\d\d$/;
if(! phone.rawValue.match( phoneRegex ) ) {
xfa.host.messageBox( "Please enter a valid phone number" );
this.rawValue = null;
}
EdwardKuk
Registered: May 14 2010
Posts: 26
Hi Harry2ca,

Thanks a lot for your help! Although that didn't work I found that my mistake was that I didnt use this.

Thanks,
Edward Kuk