lemme correct/clarify something:
"if neither radio button is checked by default, and the user submits
the form without checking one, there will be no value."
while that's true, document.form.RADIOGROUPNAME is an array. so
checking document.form.RADIOGROUPNAME.value won't work, as the array
doesn't have a value.
thanks for giving me the opportunity to clarify :)
On 5/30/07, Charlie Griefer <[EMAIL PROTECTED]> wrote:
> if neither radio button is checked by default, and the user submits
> the form without checking one, there will be no value.
>
> the correct way to validate a radio button group is to loop over the
> array and determine if one is checked.
>
> <script type="text/javascript">
> function checkform(form) {
>
> var numchecked = 0;
> for (var i=0; i<form.type.length; i++) {
> if (form.type[i].checked) {
> numchecked++;
> break;
> }
> }
>
> if (numchecked == 0) {
> alert('you did it wrong!');
> return false;
> } else {
> return true;
> }
> }
> </script>
--
Charlie Griefer
================================================
"...All the world shall be your enemy, Prince with a Thousand Enemies,
and whenever they catch you, they will kill you. But first they must catch
you, digger, listener, runner, prince with a swift warning.
Be cunning and full of tricks and your people shall never be destroyed."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279648
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4