Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

script to prevent the cursor from tabbing out if the format is wrong

Avatar

Level 4

Hi All,

I have the following script on exit event of a field on my form that I am designing, and basically if the  format is wrong it should reset the cursor back to the field unless the correct format is entered. Here is the Code:

    

              if

(this.formattedValue<>YYYYMMDD){

                   xfa.host.setFocus("Last_Name5");

             }

For some reason it is not working, and I am just wondering if someone on this forum will know why.

Thanks

LP

1 Accepted Solution

Avatar

Correct answer by
Level 4

have you tried using a validation pattern on the field of num{99999999}?

View solution in original post

4 Replies

Avatar

Level 4

Could you upload your form?  I'm mildly confused with what you are trying to accomplish by comparing a value from this, and then setting the focus to a field that I'm guessing deals with a last name

Thanks

Avatar

Level 4

Thanks, but the field name is "Last-Name". The code I have is placed on the validate event, and is as follows:

if(Last_Name.FormattedValue != "99999999"){

   xfa.host.setfocus("Last_Name");

}

Basically, what I am trying to do is prevent the cursor from moving out of the field until a true value that meets the formatted set up is met.

Thanks

LP

Avatar

Level 7

Hi Ipianwi,

Did you try placing your code on the Enter event of the next field in the tabbing order? You might have better luck that way.

djaknow

Avatar

Correct answer by
Level 4

have you tried using a validation pattern on the field of num{99999999}?