How to make atleast one to be selected on checkbox

Sandeep36
Tera Contributor

Hello,

I have below requirement,

User has to select atleast one checkbox. all these checkboxes are in a container, i made the container mandatory it did not work.

some one has soluton for it??

find_real_file.png

Thanks

12 REPLIES 12

jralph
Mega Contributor

The UI Policy no long works in London.  I have several of them and they all stopped working when I upgraded.

RudhraKAM
Tera Guru

please create an on submit client script and use below script ,, make sure to replace the checkbox with your checkbox names 

 

function onSubmit() {
	
	

		
		
		var checkboxes = ['checkbox1', 'checkbox2', 'checkbox3', 'checkbox4'];
		var isSelected = false;
		
		for (var i = 0; i < checkboxes.length; i++) {
			
			if (g_form.getValue(checkboxes[i]) == 'true') {
				isSelected = true;
				break;
			}
		}
		
		if (isSelected == false) {
			g_form.addErrorMessage('At least one  checkbox is required');
			
			return false;
		}
		
	
	
}

 

This is tested in My instance and working 

 

harshav
Tera Guru

The easiest way is to write a ui policy.

Inside that conditions section select all options you have as below.

incident is false  and

change is false  and

problem is false and

service_catalog is false and

hr is false and

knowledge is false and

approval is false and 

assignment is false and

notification is false

After that, in the UI policy section set the Options as mandatory.