How Do I Disable A Radio Button Control (List Lookup) if Checked Buttons == 2


Badge +9

What's wrong with my code?

 

var BannerCodeCB = NWF$('#' + BannerCode);BannerCodeCB.click(function() {    if(NWF$('#' + BannerCode).filter(':checked').length == 2)        NWF$('#' + BannerCode).find(":input:not(:checked)").attr("disabled", true);    else        NWF$('#' + BannerCode).removeAttr("disabled");});

 


3 replies

Userlevel 4
Badge +10

If I understand, you want to disable you choices (Check box) if the user select more than 1 item ?

So, when the user save the forms, you don't have more than 1 element.

 

You can do that without JavaScript. Create a Nintex Validation Rule, which invalidate your field if there is more dans 1element (and dispay an Error message). So if the user want to save the form, He must unselect some choices.

 

 

Badge +9

No I would like to disable all other unchecked choices when 2 checkboxes have been ticked. The idea is to prevent users from ticking more checkboxes when ticked checkbox count == 2.

 

I do not wish to invalidate the entire control.

 

This can only be done via JS.

 

Userlevel 4
Badge +9

In fact, the solution described by Nicolas works fine: you cannot submit your form if you have more than 2 items selected. If you select 3, you will have the validation rule triggered, preventing you to save the form.
He just answered with 1 items instead of 2, but the solution is still valid.
I suppose that this solution does not suit you because it is check at the page validation and not dynamically ?

Reply