Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Custom Alerts

Avatar

Level 3

Hi There,

I have a script that checks if a subform is visible. If it is visible then a text field becomes required. That part works fine now. When prompting the user I want a custom message to be displayed - something user friendly not a list of field names. The default error message associated with the nullTest property says "vendor1 is required" - that is not good enough.

So I added a line to customize that alert. Now I am getting both alerts on my test. First my custom alert (script below) and then the default alert.

a) Is it possible to prevent the default error message associated with the nullTest property?

or

b) Is it possible to customize the content in the default error message associated with the nullTest?

If none of the above are possible, is there another way to write the code to make a text field required on the visibility condition and output a custom alert?


Current Script:

if (comparativeBids.presence == "visible") {

    this.validate.nullTest = "error";

    xfa.host.messageBox("Please enter a vendor name on line 1 of the Comparative Analysis section.", "Comparative Analysis Required", 0, 0);

    }

else {

    this.validate.nullTest = "disabled"

    }

1 Accepted Solution

Avatar

Correct answer by
Level 3

Kyle, Thanks for the tip.

I researched the "mandatory"  property and it has a companion propery called "mandatoryMessage". So now the script is:

if (comparativeBids.presence == "visible") {

    this.mandatory = "error";

    this.mandatoryMessage = "Please enter a vendor name on line 1 of the Comparative Analysis section.";

    }

else {

    this.mandatory = "disabled"

    }

With just one (customizable) alert to the user

View solution in original post

4 Replies

Avatar

Level 8

What if you try this.mandatory="error" instead?

Kyle

Avatar

Level 3

No change. The form still alerts the user twice (once with my custom messageBox and second with Adobe's default for that error).

Avatar

Correct answer by
Level 3

Kyle, Thanks for the tip.

I researched the "mandatory"  property and it has a companion propery called "mandatoryMessage". So now the script is:

if (comparativeBids.presence == "visible") {

    this.mandatory = "error";

    this.mandatoryMessage = "Please enter a vendor name on line 1 of the Comparative Analysis section.";

    }

else {

    this.mandatory = "disabled"

    }

With just one (customizable) alert to the user

Avatar

Level 3

Just in case someone is interested... even though the solution above works for some reason it was making my form flash whenever the submit button was activated while the subform was visible. I thought that would freak out some of the form users so I started looking for other solutions to implement the "required if visible" condition. I started another thread on that solution because it had to do with creating dependable conditions and as a newbie I got stuck on that. If you want to see my final code here it is: http://forums.adobe.com/message/5460636#5460636