469,323 Members | 1,256 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

validating multiple groups of checkboxes

Hi,
I have a form that contains multiple groups of checkboxes that act
like radio buttons (at the clients insistance).

There is one text field that is required and 28 checkbox groups.

Here an example of a checkbox group:
<td><input type="checkbox" name="trusted" value="1" id="ck_ttt1"
onclick="...
<td><input type="checkbox" name="trusted" value="2" id="ck_ttt2"
onclick=...

There are 5 more of these "groups"

My mind is mush and I cannot get them to validate, here is what I got:
var count = 0;
for (var i = 0 ; i < form.by.length ; i++) {
if (form.by[i].checked) {count++}
}
if (count == 0) {
alert("You forgot to indicate if you are a peer, direct report,
customer, or other to the assessed.");
return false; // validation failed
} else {
return true; // validation succeded
}
var count = 0;
for (var i = 0 ; i < form.bigpicture.length ; i++) {
if (form.bigpicture[i].checked) {count++}
}
if (count == 0) {
alert("In the Leadership area, you forgot to check the big picture
option.");
return false; // validation failed
} else {
return true; // validation succeded
}

Thanks

Kim

Sep 14 '07 #1
2 6578
forbes said the following on 9/14/2007 3:17 PM:
Hi,
I have a form that contains multiple groups of checkboxes that act
like radio buttons (at the clients insistance).
If you want something that acts, looks and feels like a radio button,
then you use a radio button.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 15 '07 #2
In comp.lang.javascript message <DM********************@giganews.com>,
Fri, 14 Sep 2007 20:46:18, Randy Webb <Hi************@aol.composted:
>forbes said the following on 9/14/2007 3:17 PM:
>I have a form that contains multiple groups of checkboxes that act
like radio buttons (at the clients insistance).

If you want something that acts, looks and feels like a radio button,
then you use a radio button.

AIUI, if one wants to retain the client's business, one heeds the
client's demands, where insistent. IIRC, you have previously indicated
much the same yourself.

But the ideal answer would be to use radio buttons (type=radio) styled
to look like checkboxes.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ.
Sep 15 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Emmett Power | last post: by
8 posts views Thread by Ralph Freshour | last post: by
5 posts views Thread by Stephen | last post: by
3 posts views Thread by Darrel | last post: by
7 posts views Thread by mc | last post: by
reply views Thread by Ned Balzer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.