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

SOLVED

Using validation pattern to control visibility

Avatar

Level 2

Hi all, hoping you can help me again with a query. I'm using LiveCycle Designer ES2.

I have a text field on my form - let's say Account Number -  that has a validation pattern of text{AA999}|text{99999}  i.e it must be a 5 character string, either two letters and three numbers or 5 numbers. This is set in the Validation Pattern GUI, not in script.

What I'd like to do is control the visibility of another field - let's say Account Name - based on whether Account Number validates correctly or not. I know how to write the script to control the visibility, but not sure what test to do for it. Something like...

if (<<how do I write the test to see if it validated correctly?>> == true)

{

AccountName.visibility = "visible";

}

else

{

AccountName.visibility = "hidden";

}

Can anyone guide me as to how to do this?

Thanks

Matt

1 Accepted Solution

Avatar

Correct answer by
Level 10

if you call the validate method of the object it will return a true or false based on whether teh validation passed or failed.

So your code would look something like this:

if (fieldName.execValidate() == true)

{

AccountName.visibility = "visible";

}

else

{

AccountName.visibility = "hidden";

}

View solution in original post

0 Replies

Avatar

Level 10

Using Regular Expressions is the best approach for this requirement. But you need to write a few lines of code in javascript.

Nith

Avatar

Correct answer by
Level 10

if you call the validate method of the object it will return a true or false based on whether teh validation passed or failed.

So your code would look something like this:

if (fieldName.execValidate() == true)

{

AccountName.visibility = "visible";

}

else

{

AccountName.visibility = "hidden";

}

Avatar

Level 10

Interesting and pretty simple solution !

Thanks Paul.

Avatar

Level 2

Hi both,

Thanks for your responses - Nith yes I did think about using regular expressions but I wasn't sure of the syntax needed to check for my requirements, hence why I used the pattern editor.

Paul - thanks for your help - this works perfectly.

Matt