Expand my Community achievements bar.

SOLVED

Limit number of selection in Dropdown AEM 6.5

Avatar

Level 2

Hi There,

 

 I am currently working on dropdown/Select in AEM 6.5, I want to  limit the number of selected options , the user must only select certain maximum number of options say 2 or 3  options and  the field must be disabled unless they remove the previously selected option.

 

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

HI,

 

  • This can be done by associating "validation" property to the desired dialog field and include desired logic in JS targeting the respective "validation" property. (Need not exactly be "validation" property, it can be granite:class or granite:id. Idea is to have an identifier for the respective dialog field and write logic targeting the same.)
  • Field Limit can be configured at dialog field level via "granite:data" node. (Will be available as data attribute on the field and the values authored can be compared against the allowed limit)

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

HI,

 

  • This can be done by associating "validation" property to the desired dialog field and include desired logic in JS targeting the respective "validation" property. (Need not exactly be "validation" property, it can be granite:class or granite:id. Idea is to have an identifier for the respective dialog field and write logic targeting the same.)
  • Field Limit can be configured at dialog field level via "granite:data" node. (Will be available as data attribute on the field and the values authored can be compared against the allowed limit)