Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Limited Checkbox Selection

@shanebp

Moderator

javascript:

function checkboxlimit(checkgroup, limit){
	for (var i=0; i<checkgroup.length; i++){
		checkgroup[i].onclick=function(){
		var checkedcount=0
		for (var i=0; i<checkgroup.length; i++)
			checkedcount+=(checkgroup[i].checked)? 1 : 0
		if (checkedcount>limit){
			alert("You can select a maximum of "+limit+" boxes.")
			this.checked=false
			}
		}
	}
}		
checkboxlimit(document.forms.your_form_name_or_id['field_name[]'], 5);
Skip to toolbar