Expand my Community achievements bar.

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

Validation Script Message

Avatar

Former Community Member
Is it possible to have the Caption of a field to be referenced in the Validation Script Message?



Or



The focus to be put back on the field?
2 Replies

Avatar

Former Community Member
Be cautious using focus on validation. It is very easy to create a closed loop.



For your validation message, you can set the validationMessage to the caption in the initialize event as follows:



this.validationMessage = this.resolveNode("caption.value.#text").value + " is invalid.";



Suppose you have a numeric field "qty", the Caption is set to Quantity", and the JavaScript validation event is "this.rawValue > 10;", if validation fails the message will be "Quantity is invalid.".



Steve

Avatar

Level 2

I'm looking for something similar.

When the user submits the form, I want to run through and verify all the required fields are filled in, and then have a message box pop up saying "Please enter the following required information: *caption of missing field*"

I'm not sure how to manipulate the code in your answer to do this.

Thanks for your help!!