Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

AEM forms - Mandatory alert not working in HTML Render

Avatar

Level 2

Hi All,

 

I have to display the subform based on the dropdown value and once the subform is visible there are some fields that needs to mandatory. I have tried in all ways but is not working, it would be great if  someone help on it, as the development is on hold.

 

Sample script 

if(this.rawValue == "Accept")
{
Page1.Accept.presence = "visible";
Page1.Accept.TextField1.mandatory = "error";
Page1.Denial.presence = "hidden";
Page1.Denial.TextField3.mandatory = "disable";
}
else if(this.rawValue == "Denial")
{
Page1.Accept.presence = "hidden";
Page1.Accept.TextField1.mandatory = "disable";
Page1.Denial.presence = "visible";
Page1.Denial.TextField3.mandatory = "error";
}

 

Thank you in advance

 

Regards,

Apurva 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Employee

Hi @Apurva1_12 ,

Could you please use the complete SOM expression (i.e. xfa.resolveNode("form1.#subform.TextField1")) instead of "Page1.Denial.presence" in your script? Kindly test it and let me know if it works as expected. If it doesn't, please share a sample XDP file containing the relevant scripts for further analysis.

 

Thanks,

Vijay

 

Avatar

Employee

Hi @Apurva1_12,

 

Can you please try the below code snippet. I tried on one of my forms and the script is working properly. if you still face the issue, kindly share a sample form and I can help you in updating the code.

if (this.rawValue == null || this.rawValue == "") { this.mandatory = 1; // Make the field mandatory } else { this.mandatory = 0; // Make the field optional (if it had a value) }

Thanks
Pranay