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.

Yes or No Field must be manadatory

Avatar

Level 2

I have a form that has a list of yes or no questions which must be completed, they are set at user required and i have a small script that has brings up a message if the user does not complete question and tabs out and no entry is entered the message appears. the user then enters yes however the error comes up again as they have come out of the next question without answering it and have to go back, it is a bit messy.

Can anyone think of a different way of doing it?

on exit

if (this.rawValue == '' || this.rawValue == null){

xfa.host.messageBox("Please enter yes or no.");

}

2 Replies

Avatar

Level 6

not sure if this will solve the issue you're having but your first statement should include two quotations....

this.rawValue == ''"



Avatar

Level 3

You can add in a line to set the focus back to the empty field

if (this.rawValue == "" || this.rawValue == null) {

xfa.host.messageBox("Please enter yes or no.");

xfa.host.setFocus("$");

}

you can also add in a line to set the border to red or highlight the field when the field is exited and empty to indicate it needs to be filled

if (this.rawValue !== null) {

    this.ui.oneOfChild.border.fill.color.value = "225,255,225"; // green tinge

}

else {

    this.ui.oneOfChild.border.fill.color.value = "255,225,225"; // red tinge

}