AEM forms - Mandatory alert not working in HTML Render | Community
Skip to main content
Level 2
July 16, 2025

AEM forms - Mandatory alert not working in HTML Render

  • July 16, 2025
  • 1 reply
  • 639 views

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 

1 reply

Adobe Employee
July 23, 2025

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

 

Adobe Employee
July 30, 2025

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