Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Conditional Required Field - Need help with refreshing

Avatar

Former Community Member

Am using this code to require entry in a field if selection #30 is chosen from a drop-down.  In testing it works but only after I select things twice, it seems to also need to refresh/clear out the values before it will make the field required.  Example if I select any other choice the email goes ok, and the first time I select #30, it goes through, but if I select #30 a 2nd time, I get the pop-up message telling me at least one of the required fields has not been completed . . . . which is a 2nd part to this question.  Is it possible to tell the person which field is missing data, or automatically place the cursor in the field?  That is not as critical as the refreshing part.  Thank you!


if

(this.rawValue =='30')

{

Q11_Comments.mandatory

= "error";

}

else

{

Q11_Comments.mandatory

= "disabled";

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

Dropdown selections don't register until you exit the field, so your code would probably work on the Exit event.

To get it to work when the selection is made you can use xfa.event.newText so try this as your if statement:

if (this.boundItem(xfa.event.newText) == '30')

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Dropdown selections don't register until you exit the field, so your code would probably work on the Exit event.

To get it to work when the selection is made you can use xfa.event.newText so try this as your if statement:

if (this.boundItem(xfa.event.newText) == '30')

Avatar

Former Community Member

Thank you very much.  Am not sure I understand what you mean about xfa.event.newText, but I moved the existing code to the exit event instead of change and its seems to work fine, thank you!

Avatar

Level 10

If you use xfa.event.newText then dropdown list changes will work when the selection is made as opposed to waiting until the field is exited.

Avatar

Former Community Member

Ok, that is helpful, I'm with you now.  Tested and changed back to the change event with below and it works like a charm, thank you for all your help.

 

if

(this.boundItem(xfa.event.newText) == '30')

{

Q11_Comments.mandatory = "error";

}

else

{Q11_Comments.mandatory = "disabled";

}