If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
These forums remain online primarily for archival purposes. While posting is still possible, it should not be considered a means for support. Please login to our portal and submit a ticket if you require assistance and we'll be more than happy to assist you.
Regular updates are posted to our blog and we will continue to post important notices to the Script Security forum section here. You can subscribe to that forum to automatically receive notifications.
I have a form and have mutiple checkboxes. Is there a way to force the
user to check at least 2 checkboxes from a long list? If they only check one it will not let them submit but gives an error?
I use a script from http://jsval.fantastic-bits.de to validate everything I haven't used it for checkboxes yet so I'm not positive if it works on them or not. Worth a try though.
this javascript goes into the body section of the html page
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
function CountBoxes() {
var Count = 0
if (document.test.cb1.checked)
{Count = Count + 1}
if (document.test.cb2.checked)
{Count = Count + 1}
if (document.test.cb3.checked)
{Count = Count + 1}
if (Count < 2)
{
alert('Choose at least 2 items')
document.test; return false;
}
}
// -->
</script>
this is how the form with the checkboxes could look like. make sure the name of the form (in this example "test") and the names of the checkboxes are matching with the ones used in the javascript
Comment