• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Require at least one checkbox?

Participant ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

I have a form which dynamically spits out my users so they can be assigned to a project. How can I require at least one of the checkboxes that it spits out or is their a better method to my madness?
TOPICS
Advanced techniques

Views

727

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Dec 28, 2006 Dec 28, 2006
server side would be:

<cfif NOT structKeyExists(form, 'whichLogin')>
handle error here
</cfif>

client side would be:

1) add an onsubmit="return validate(this);" in your form tag.
2) add the following code block:


Votes

Translate

Translate
Guest
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

server side would be:

<cfif NOT structKeyExists(form, 'whichLogin')>
handle error here
</cfif>

client side would be:

1) add an onsubmit="return validate(this);" in your form tag.
2) add the following code block:


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: mikeap
I have a form which dynamically spits out my users so they can be assigned to a project. How can I require at least one of the checkboxes that it spits out or is their a better method to my madness?

Instead of check boxes use radio buttons or a select.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

but radio buttons or a select (unless the latter has the multiple attribute assigned) would only allow one selection. if I understood correctly (and don't get me wrong, it's a distinct possibility that I don't <g>), the OP wants to make sure at -least- one of the records is chosen (implying that there could be more).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

LATEST
You could use a select allowing for multiple selections but I prefer to use checkboxes because it allows me greater control but I guess it's just a matter of preference.

Thanks CJ for the answer! I figured it would be a Javascript solution ... which I know barely anything about. Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation