We have a lookup field in our SharePoint list. Which comes as a drop-down list and are set to select multiple items.
We want to limit the selection to maximum of 6 and from a predefined strings. If the items selected from the drop-down list greater than 6 or value selected is not from the set of strings we wanted then it should thrown a validation error. How do i do this?
You can use a custom validator to make sure that no more than six values are selected. Please see the code example below.
Please LookupFieldName with the internal name of the lookup field.
And you can specify any error text that will be displayed to a user, just replace ValidationText in the code.
And could you please clarify what do you mean under 'predefined strings'. What are the conditions? More details explanation and some screenshots would be helpful.