Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Focus after validation error

Avatar

Former Community Member
Is it possible to re-set focus to an object after a validation (pattern) error? I don't want the user being able to exit an object when there is a validation error.
6 Replies

Avatar

Former Community Member
-Bump-



Is this not possible to do or do I need to clearify my problem? :)

Avatar

Former Community Member
Hi!



The problem isn't to set focus to the control but to set focus after the pattern validation. Is there any way to determine if the pattern validation errors and then set focus?



As it is now, a dialog shows and says "Your postalcode must be 5 digits" and then the cursor jumps to the next textfield. I want the cursor to return to the control that didn't verify correctly.

Avatar

Former Community Member
To be able to do that you will have to use scripting validation instead of the built in validation.

Avatar

Former Community Member
The easiest way to convert a picture validation to a script validation is to use the formcalc format() function.

E.g. the formcalc script to validate a US zip code would look like:



format("text{99999}", $) <> ""

Avatar

Former Community Member
That's a pretty big job to do that but I am starting to realize that I don't have any other option. Thanks for your help!