close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

require at least one checkbox?

Thread began 2/17/2020 3:09 pm by art226587 | Last modified 2/25/2020 4:55 pm by Ray Borduin | 40 views | 5 replies |

art226587

require at least one checkbox?

I have a form with a group of checkboxes where the user must select at least one, but can select more than one in any combination. I have no idea how to set up validation to require at least one of them. Below is the form code I'm using. Thanks!

<div class="lineGroup">
<label class="checklabel" for="study_print"><input type="checkbox" name="study_print" id="study_print" value="yes" class="formCheckboxField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("rrf2017insert2","study_print"):""),"yes"))) {echo "checked=\"checked\"";} ?> tabindex="27" title="Please enter a value."> Print</label>
<label class="checklabel" for="study_digital"><input type="checkbox" name="study_digital" id="study_digital" value="yes" class="formCheckboxField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("rrf2017insert2","study_digital"):""),"yes"))) {echo "checked=\"checked\"";} ?> tabindex="27" title="Please enter a value.">Digital</label>
<label class="checklabel" for="study_combined"><input type="checkbox" name="study_combined" id="study_combined" value="yes" class="formCheckboxField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("rrf2017insert2","study_combined"):""),"yes"))) {echo "checked=\"checked\"";} ?> tabindex="27" title="Please enter a value.">Print + Digital</label>
</div>
Sign in to reply to this post

Ray BorduinWebAssist

You would need some hand coding to get it working. Here is some sample code that should work. Just add this before the server validation code:

php:
<?php

$checkedBoxes 
0;
if (isset(
$_POST["study_print"])) $checkedBoxes++;
if (isset(
$_POST["study_digital"])) $checkedBoxes++;
if (isset(
$_POST["study_combined"])) $checkedBoxes++;
?>



Then you can validate the value of <?php echo($checkedBoxes); ?>

Using number validation to validate that it is greater than zero.

Sign in to reply to this post
Did this help? Tips are appreciated...

art226587

Thanks a lot, Ray. I added the code above where it appears the server validation begins on my page (see below). Though, I'm not quite sure about the second part you mention "Using number validation..." Could you explain that to this php noob?

Sign in to reply to this post

Ray BorduinWebAssist

Open your server validation and for the validated field put: <?php echo($checkedBoxes); ?>

and for the validation type choose number validation.

Then click the add button and set the number of checkboxes required.

Sign in to reply to this post
Did this help? Tips are appreciated...

art226587

Hey, can we set up a zoom call for you to help me with this? I'm getting all cross-eyed looking at it.

Sign in to reply to this post

Ray BorduinWebAssist

Just call the number at the bottom of the website and I can help.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...