Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit Checkbox to a specific count #174

Open
elanasparkle opened this issue Sep 15, 2022 · 0 comments
Open

Limit Checkbox to a specific count #174

elanasparkle opened this issue Sep 15, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@elanasparkle
Copy link
Collaborator

elanasparkle commented Sep 15, 2022

Limit how many checkmarks can be selected

Name | Checkbox
Reporter | Elana D.
Submit Date | 9/14/2022
Summary | Limit checkmarks on a specific number specified in the editor

Put settings in editor that will set this variable from there or not at all. Below code does this for you if you change the name of your checkmark and put in functions.php. This would need to be added to other selection boxes as well.

`
function weforms_limit_checkbox() {
?>
<script type="text/javascript">
(function($) {

	var max_limit = 3; // Max Limit
	var last; //last checked
	$(".wpuf_invoice_price_6:input:checkbox").each(function (index){
		this.checked = (".wpuf_invoice_price_6:input:checkbox" < max_limit);
	}).change(function (){
		if ($(".wpuf_invoice_price_6:input:checkbox:checked").length > max_limit){
			$(last).prop('checked', false);
		}
		last = this;
	});

})(jQuery);
</script>
@elanasparkle elanasparkle added the enhancement New feature or request label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant