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.

How to remove invalid user-entered data?

Avatar

Level 1

For example, if a user enters 5 digits (or any amount of digits that is not 8) into Field1 instead of a 8 digits and tries to go to the next field, I want to be able to trigger a validation warning and stop the user from continuing to populate the rest of the form until they either a) deleted input or b) entered in an 8-digit number. In short, I don't want any of the form fields to be able to retain invalid data.

I am thinking about something akin to Excel's "data validation" process when "ignore blank" is unchecked.

Any help would be appreciated.

1 Reply

Avatar

Level 7

Add this to the exit event of your field:


if (!this.isNull) if(this.rawValue.length != 8){


  xfa.host.messageBox("You must enter 8 characters or leave this blank.");


  xfa.host.setFocus(this);


}



The extra "if" statement ensures that the text field isn't empty before checking the length to keep from throwing an error.