Forum Moderators: open

Message Too Old, No Replies

radio button

         

rorlini

2:57 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



How do I check whether a certain value is checked off on a radio button?

The group name is "send". The value I want checked is whether it is "sendemail". If it is I want an alert to ask that the subject is required.

Thx.

Robert O.

Here is aprt of what I have so far:
if((form.send.value).checked && (trim(form.subject.value).length == 0))
{
alert("Email subject is required.");
return false;

Birdman

3:51 pm on Feb 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to add the array index because "send" is an array. So, assuming "sendemail" is the first radio button, you would use zero(0) as the index. Also, do not use "value".

if(form.send[0].checked && (trim(form.subject.value).length == 0))
{
alert("Email subject is required.");
return false;

Another note. Be sure to test on IE and Mozilla(et al) because I think they differ in the way you refer to certain objects.