Expand my Community achievements bar.

Converting AcroForms javascript to Designer javascript

Avatar

Former Community Member
In Acrobat 6.0, I defined a form's field test script as;



var re = /^[A-Z][a-z]+ [A-Z] [A-Z][a-z]+$/



if (re.test(event.value) == false){

.

.

.... to test a field for a user's Firstname, Middle Initial, Lastname.



How do I write the same validation script in Designer 7?
3 Replies

Avatar

Former Community Member
If the script is in the field's validate event then all you should have to do is change event.value to this.rawValue and it should work. If not I'll take a closer look.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Chris, I made the change but I got several lines of errors.



Here is the code to validate a name field;



var re = /^[A-Z][a-z]+ [A-Z] [A-Z][a-z]+$/



if (re.test(this.rawValue) == false)

{

xfa.host.messageBox("You did not enter a valid name. You

need to enter First, middle initial, and last name.")

}



And these are the error messages;



SyntaxError: missing ( before condition

3:XFA:F[0].P1[0].reqName[0]:mouseExit

SyntaxError: missing ( before condition

3:XFA:F[0].P1[0].reqName[0]:mouseExit

SyntaxError: missing ( before condition

3:XFA:F[0].P1[0].reqName[0]:mouseExit

SyntaxError: unterminated string literal

4:XFA:F[0].P1[0].reqName[0]:mouseExit

SyntaxError: unterminated string literal

4:XFA:F[0].P1[0].reqName[0]:exit

SyntaxError: unterminated string literal

4:XFA:F[0].P1[0].reqName[0]:validate

SyntaxError: unterminated string literal

5:XFA:F[0].P1[0].reqName[0]:mouseExit

SyntaxError: unterminated string literal

5:XFA:F[0].P1[0].reqName[0]:validate

Avatar

Former Community Member
I copy/pasted the script you list above and it works fine, I didn't change anything except to remove the line break in the string in messageBox() (which was probably added by the forum software).



The error messages list errors in three different events, mouseExit, exit, and validate. So what are the exact scripts you have in each of those events?



Chris

Adobe Enterprise Developer Support