A radio group is stored as an array, so you would need to loop over the 
array and check to see if any of the buttons were checked --
flag = 0;
for (i=0;i<form.sitetype.length;i++) {
if (form.sitetype[i].checked) {
flag = 1;
}
}
if (flag == 0) {
window.alert('Please enter site type') ;
}

There's probably a more streamlined way to do it, this is off the top of my 
head.

- -Josh



----- Original Message ----- 
From: "Orlini, Robert" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Friday, April 28, 2006 9:29 AM
Subject: OT: Group field name


> Hello,
>
> I have a field named "sitetype" which is a group name setup as a radio 
> button.
>
> The script below does not seem to recognize it since it does not generate 
> the alert when the radio button is not selected. All the cases are correct 
> for the name. Is there something missing in the JavaScript below or is a 
> radio button group field name different?
>
> The "onsubmit="return checkform(this);" section is in the <form> 
> parameter.
>
> Thanks.
>
> RO
> HWW
>
> <script language="JavaScript" type="text/javascript">
> <!--
> function checkform ( form )
> {
>  // ** START **
>  if (form.sitetype.value == "") {
>    alert( "Please enter a site type." );
>    form.sitetype.focus();
>    return false ;
>  }
>  // ** END **
>
>  return true ;
> }
> //-->
> </script>
>
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239065
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to