Multiselect maxCount

I need to set a limit to how many options a user can select in a multiselect.

image

I see in the API doc that the multiselect has a property called maxCount, but it is not clear to me what that controls and there is no option to set that value on the interface.

I tried setting it with a script, but it did not set change the behaviour as expected:
image

So what does Multiselect.maxCount actually controls? and how can I use/set it?

maxCount is the representation of the validation rule "Max Items" on the multi-select component.

I don't think you can override the components ability to add new items if they are in the list of options but you could possibly build around the idea of disabling the component once the max number of picks have been made and then if a pick was made in error having a mechanism of clearing the values out.

Ah, ok that clears that out then.