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

Script text fields

StacyMac
Registered: Jul 22 2010
Posts: 3
Answered

Help please...
I am trying to find script for a text field that will give a warning message if the user enters a specific set of characters. For example if the user enters M100123 and tabs out of the field a warning message will appear with instructions. If the user enters M100122 and tabs out of the field no warning message will appear.
 
Can anyone help me?

Stacy Macpherson

My Product Information:
Acrobat Pro Extended 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Is your form being created in Acrobat or LiveCycle Designer?


George Kaiser

StacyMac
Registered: Jul 22 2010
Posts: 3
The form is created in Acrobat. I am using 9.0 Pro Extented.

Stacy Macpherson

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Accepted Answer
The Windows version provides both Acrobat and LiveCycle Designer.

You can use the field's 'Validate' tab to code a custom script for the validation. Since you will be in the current field being updated, you should use the 'event.value'

// check value for the following string
if(event.value == "M100123") {
// match so issue an alert
app.alert("\"M100123\" is not a valid entry, please retry", 1, 2);
// set event return code for failure
event.rc = false;
}

If you want upper and lower cases of the inputted value to be validated you will need to add additional code to provide for that requirement. The above code assumes there will be no leading or trailing blanks.

George Kaiser

StacyMac
Registered: Jul 22 2010
Posts: 3
George this great! Thank you!

Just what I need.



Stacy Macpherson