Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Make an Adaptive Form Field required in JavaScript

Avatar

Level 2

I have an Adaptive Form and I'd like to make a given field required via JavaScript.  I have tried the following:

field.mandatory = "error"

field.mandatory = "true"

field.mandatory = true

field.required = "error"

field.required = true

I have also tried all of the above together with field.validationsDisabled = false and validationsDisabled = "false".

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I added a field and submit button in an adaptive form.

On field initialize event in Code editor, below works for me when I submitted the form without entering any data.

this.mandatory="true";

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

I added a field and submit button in an adaptive form.

On field initialize event in Code editor, below works for me when I submitted the form without entering any data.

this.mandatory="true";

Avatar

Level 1

This unfortunately does not work for me.  When I submit the form, it's not respecting this change.  I've tried mandatory="true" on the outer div element surrounding the form component as well as on the radio button group itself.

Avatar

Community Advisor

 

Took radio group also, and it's working, see attached

 

Capture.JPG

 

 

Capture2.JPG