Limit a multi-select list box to a maximum of 3 selected items
This InfoPath demo is the completed solution for recipe 79 of InfoPath 2013 Cookbook in which data validation is added to a multiple-selection list box so that a user can only select a maximum of 3 items in the multiple-selection list box.
In recipe 79 you will learn how to add data validation to a multiple-selection list box so that a user can only select a maximum of 3 items in the multiple-selection list box.
Get more solutions from InfoPath 2013 Cookbook which is available on Amazon.com
Watch the next InfoPath demo: Auto-populate a drop-down list box with past and future dates
InfoPath demo video transcript:
Here I'm in InfoPath Designer 2013 where I've got this InfoPath form template that has a multiple-selection list box control on it. As you can see here on the Rules task pane, InfoPath does not allow you to add custom validation rules to a multiple-selection list box. That's because this control comes with its own validation in the form of requiring users to select at least one item in the multiple-selection list box.
Recipe 79 of InfoPath 2013 Cookbook shows you a way how you can add data validation to a multiple-selection list box that goes beyond requiring users to select only one item in the multiple-selection list box.
Here I'm in SharePoint 2013, where I've already published an InfoPath form template to this SharePoint form library. So if I click new document to add a new form, you'll see that as soon as the InfoPath form opens, it will display this multiple-selection list box containing these 5 items.
I can go ahead and start selecting items in this multiple-selection list box, and as soon as I select more than 3 items, you'll see this error message appear telling me I'm only allowed to select a maximum of 3 items.
I can go ahead and save the form, and when I try to do that you'll see that this message will pop up saying that "This form contains validation errors." But I'm still allowed to save it, so I can go ahead and save it if I want to.
However, if a form has been enabled to be submitted, and I hit the Submit button, you'll see this message appear saying, "InfoPath cannot submit the form because it contains errors." And I'm only allowed to close this message box, so I cannot continue unless I deselect items and get 3 or less items in the multiple-selection list box, so that the error message disappears, and then I can go ahead and hit the Submit button and successfully submit the form.
Related InfoPath Demo Videos:
- Populate a drop-down list box with dates excluding weekends
- Limit the amount of lines in a multi-line text box
- Shrinking drop-down list in a repeating table
- Auto-populate a drop-down list box with past and future dates
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.