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

Force Feild upon Validation Error

Avatar

Level 4

I have a Date Field with the Validation Pattern date{MM/DD/YYYY}. Is there a way once the user get the error message the cursor goes back to the Date Field instead of going to the next field.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You should be able to add the following JavaScript code to the exit event of the date field

if (this.formattedValue === this.rawValue)

{

    xfa.host.setFocus(this);

}

This works because the only time the formattedValue is the same as the rawValue is when then edit pattern validation fails (or when then edit pattern is YYYY-MM-DD ... the rawValue pattern).

Note: this goes against Adobe's  guidelines for designing forms, they reckon the user should be able to move though the form as they wish but there are a lot of real forms out there that work this way.

Regards

Bruce

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

Hi,

You should be able to add the following JavaScript code to the exit event of the date field

if (this.formattedValue === this.rawValue)

{

    xfa.host.setFocus(this);

}

This works because the only time the formattedValue is the same as the rawValue is when then edit pattern validation fails (or when then edit pattern is YYYY-MM-DD ... the rawValue pattern).

Note: this goes against Adobe's  guidelines for designing forms, they reckon the user should be able to move though the form as they wish but there are a lot of real forms out there that work this way.

Regards

Bruce

Avatar

Level 4

Thanks Bruce this worked great

Best regards

Parre