Looking a bit further...

form.sitetype.value will be undefined.

You will have to loop over the radio buttons checking each to see if it's
checked. Try something like:


<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{

  // ** START **
  for ( var i = 0; i < form.sitetype.length; i++ ) {

    if ( form.sitetype[i].checked ) {
      alert("One is checked!");
    }

  }

  // ** END **

  return true ;
}
//-->
</script>

Add some more logic and it should work as validation.

Adrian

-----Original Message-----
From: Orlini, Robert [mailto:[EMAIL PROTECTED]
Sent: 28 April 2006 17:30
To: CF-Talk
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:239064
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