Restrict the selection count in choice (checkbox list)

Drag and Drop DataLabel control to view canvas and Change its name to dlbScript
Drag and Drop Choice control to view canvas
Restrict Choice Selection -1
Change the name of Choice list to “ChkListUsers”
Set property Display Type to Check Box List

Restrict Choice Selection -2

Add data source to Choice control and changes the properties as per your requirement.
For dlbScript control do the following changes in properties
1. Set Literal property Checked
2. Click on Oval to add Expression for dlbScript control

Restrict Choice Selection -3

3. Add the below jQuery code

Restrict Choice Selection -4.jpg

Add jQuery code between the Script tag.

 

$("[name='ChkListUsers']").change(function(){
if($(':checked').length == 1){
$("[name='ChkListUsers']").not(':checked').prop('disabled',true);
}
if($(':checked').length == 0){
$("[name='ChkListUsers']").not(':checked').prop('disabled',false);
}
});

4. Once done click on Ok and then on Finish button for view.

Result:

Restrict Choice Selection -5.jpg

  • On selecting User 3 Other Users selection will be disabled.
  • Once you Unselected user 3 all users will be again selectable.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s