# HG changeset patch # User Nicholas Jillings # Date 1473348018 -3600 # Node ID 172c76d9414b845867238e9ae762f2d877ad98f1 # Parent bc6edd2c8772d86345bb7a20d41097f59f1f934b Survey checkbox now supports min and max to define how many options should be selected #17 diff -r bc6edd2c8772 -r 172c76d9414b js/core.js --- a/js/core.js Thu Sep 08 11:05:23 2016 +0100 +++ b/js/core.js Thu Sep 08 16:20:18 2016 +0100 @@ -915,6 +915,32 @@ console.log("Checkbox: "+ node.specification.statement); var inputs = this.popupResponse.getElementsByTagName('input'); node.response = []; + var numChecked = 0; + for (var i=0; i 1) { + msg += "s"; + } + interfaceContext.lightbox.post("Error",msg); + return; + } + } + else { + if (numChecked < node.specification.min || numChecked > node.specification.max) { + if (node.specification.min == node.specification.max) { + interfaceContext.lightbox.post("Error","You must only select "+node.specification.min); + } else { + interfaceContext.lightbox.post("Error","You must select between "+node.specification.min+" and "+node.specification.max); + } + return; + } + } + } for (var i=0; i - + Please enter your name. - + Please select with which activities you have any experience (example checkbox question)