I try alot of way but still cant the radio button to work. i need the user to select one of them else an error msg will appear.

I got the error msg to appear but it still load over to the next page as if i selected the gender.

<html>
<head><title> Kelvin's Guestbook </title>
<script language="Javascript">

function validate_length(field)
{
   with(field)
   {
	if (value.length == 0)
	{
		alert("Pls Enter Your Name!"); return false;
	}else return true;

   }
}
function validate_email(field)
{
   with (field)
   {
	apos=value.indexOf("@");	
	dotpos=value.lastIndexOf(".");	
	if (apos<1||dotpos-apos<2)
	{
		alert("Not a valid e-mail address!"); return false;
	}else return true;
   }
}
function validate_gender(field)
{
   with (field)
   {
	var male = document.getElementById("male");
	var female = document.getElementById("female");
	if (male.checked)
	{
		
	}	
	if (female.checked)
	{
		
	}
	else
	{
		alert("Pls Select Your Gender");return false;
	}
   }
}


function validate_form(thisform)
{
   with (thisform)
   {
	if (validate_length(yourname) == false)
	{
		yourname.focus(); return false;
	}
	if (validate_email(email)==false || validate_email(email)==false)
	{
		email.focus(); return false;
	}
	if (validate_gender(gender) == false)
	{
		gender.focus(); return false;
	}
   }
}
function startclock()
{
var thetime=new Date();

var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";

if (nhours>=12)
    AorP="P.M.";
else
    AorP="A.M.";

if (nhours>=13)
    nhours-=12;

if (nhours==0)
   nhours=12;

if (nsecn<10)
 nsecn="0"+nsecn;

if (nmins<10)
 nmins="0"+nmins;

if (nday==0)
  nday="Sunday";
if (nday==1)
  nday="Monday";
if (nday==2)
  nday="Tuesday";
if (nday==3)
  nday="Wednesday";
if (nday==4)
  nday="Thursday";
if (nday==5)
  nday="Friday";
if (nday==6)
  nday="Saturday";

nmonth+=1;

if (nyear<=99)
  nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
 nyear+=1900;

document.clockform.clockspot.value
=nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nmonth+"/"+ntoday+"/"+nyear+","+nday;


setTimeout('startclock()',1000);

} 

</script>
</head>
<body>

<FORM name="clockform">
Current Time: <INPUT TYPE="text" name="clockspot" size="32">
</FORM>
<SCRIPT language="JavaScript">
startclock();
</SCRIPT>

<Center>

<form name="guestbook" action="1.html" 
 onsubmit="return validate_form(this);" method="post">

	 <br>Name : <input type="text" name="yourname" value="">
	 <br>Email: <input type="text" name="email" size="30">
	 <br>Gender: <input type="radio" name="gender" value="Male" id="Male">Male
		  <input type="radio" name="gender" value="Female" id="Female">Female
	 <br>Comments: *Optional
	 <br><textarea cols="50" rows="8" name="Coments"></textarea>
	 <br><input type="submit" name="submit" value="Sign GuestBook">
	     <input type="Reset" name="Reset" value="Reset">
</form>
</Center>
</body>
</html>

Pls reply asap for a solution, need to complete it by next week. and can only start designing the background n stuff after all the field are correct thk.

commented: bad code style +0

only can use javascript nothing else. thk again

You know what makes ur life hell here.

Yes your Code itself. What the hell u have coded. No code tags.
As u r a new poster, I am solving ur problem.

Here is ur code that i modified (is this was ur code!!)

<html>
<head><title> Kelvin's Guestbook </title>
<script language="Javascript" type="text/javascript">

function validate_length(field)
{
with(field)
{
        if (value.length == 0)
       {
                alert("Pls Enter Your Name!"); return false;
        }else return true;

}
}


function validate_email(field)
{
with (field)
{
         apos=value.indexOf("@");
         dotpos=value.lastIndexOf(".");
         if (apos<1||dotpos-apos<2)
        {
                  alert("Not a valid e-mail address!"); return false;
        }else return true;
}
}


function validate_gender(gM, gF)
{

	//alert("In");
	//var male = document.getElementById("Male");
	//var female = document.getElementById("Female");
	if (gM.checked)
	{
		return true;
	}
	if (gF.checked)
	{
		return true;
	}

	alert("Pls Select Your Gender");
	return false;


}

/**/
function validate_form(thisform)
{
with (thisform)
{
	if (validate_length(yourname) == false)
	{
		yourname.focus(); return false;
	}
	if (validate_email(email)==false || validate_email(email)==false)
	{
		email.focus(); return false;
	}
	if (validate_gender(genderM, genderF) == false)
	{
		genderM.focus(); return false;
	}
}
}


function startclock()
{
	var thetime=new Date();

	var nhours=thetime.getHours();
	var nmins=thetime.getMinutes();
	var nsecn=thetime.getSeconds();
	var nday=thetime.getDay();
	var nmonth=thetime.getMonth();
	var ntoday=thetime.getDate();
	var nyear=thetime.getYear();
	var AorP=" ";

	if (nhours>=12)
		AorP="P.M.";
	else
		AorP="A.M.";

	if (nhours>=13)
		nhours-=12;

	if (nhours==0)
		nhours=12;

	if (nsecn<10)
		nsecn="0"+nsecn;

	if (nmins<10)
		nmins="0"+nmins;

	if (nday==0)
		nday="Sunday";
	if (nday==1)
		nday="Monday";
	if (nday==2)
		nday="Tuesday";
	if (nday==3)
		nday="Wednesday";
	if (nday==4)
		nday="Thursday";
	if (nday==5)
		nday="Friday";
	if (nday==6)
		nday="Saturday";

	nmonth+=1;

	if (nyear<=99)
		nyear= "19"+nyear;

	if ((nyear>99) && (nyear<2000))
		nyear+=1900;

	document.clockform.clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nmonth+"/"+ntoday+"/"+nyear+","+nday;


	setTimeout('startclock()',1000);

}

</script>
</head>
<body>

<FORM name="clockform">
Current Time: <INPUT TYPE="text" name="clockspot" size="32">
</FORM>
<SCRIPT language="JavaScript">
startclock();
</SCRIPT>

<Center>

<form name="guestbook" action="1.html"onsubmit="return validate_form(this);" method="post">

<br>Name : <input type="text" name="yourname" value="">
<br>Email: <input type="text" name="email" size="30">
<br>Gender: <input type="radio" name="genderM" value="Male" id="Male">Male
<input type="radio" name="genderF" value="Female" id="Female">Female
<br>Comments: *Optional
<br><textarea cols="50" rows="8" name="Coments"></textarea>
<br><input type="submit" name="submit" value="Sign GuestBook">
<input type="Reset" name="Reset" value="Reset">
</form>
</Center>
</body>
</html>

Now figure out what was wrong in ur code.

Ya very new to this lol, thk for ur help.

Only got 2 lesson on it and the teacher want us to create something like this LOL.

Sry to trouble the ppl here again but i need it to be able to select either male or female.

What luckychap did work but it can select both.

hey just want everythin to done here!!

Show some effort dude.

Still cant get the radio button to work, if i nv select it giv me the msg but still load to the page as if i select a choice. Can help see where i went wrong ??

<html>
<head><title> Guestbook </title>
<style>
H1, H2, H3, H4, H5, H6 {color:#D4A017; text-align:center}
</style>
<script language="Javascript" type="text/javascript">

	function validate_length(field)
	{
	with(field)
	{
	        if (value.length == 0)
	       {
	                alert("Pls Enter Your Name!"); return false;
	        }else return true;
	 
	}
	}
	 
	 
	function validate_email(field)
	{
	with (field)
	{
	         apos=value.indexOf("@");
	         dotpos=value.lastIndexOf(".");
	         if (apos<1||dotpos-apos<2)
	        {
	                  alert("Not a valid e-mail address!"); return false;
	        }else return true;
	}
	}
	 
	function validate_gender(gender) 
	{
		var genderChecked 
		for (var i=0; i<document.guestbk.gender.length; i++) 
		{
		if (document.guestbk.gender[i].checked) 
		{
		genderChecked = document.guestbk.gender[i].value
		}
		
	}
		if(!genderChecked)
		{ 
			alert("Pls Select Your Gender")
	}else return true;
	
	}
	

	function validate_form(thisform)
	{
	with (thisform)
	{
		if (validate_length(yourname) == false)
		{
			yourname.focus(); return false;
		}
		if (validate_email(email) == false)
		{
			email.focus(); return false;
		}
		if (validate_gender(gender) == false)
		{
			gender.focus(); return false;
		}
				
	}
	} 
</script>
</head>
<body>

<h1>Welcome to my GuestBook</h1>

<Center>
 
<form name="guestbk" action="1.html" onsubmit="return validate_form(this);" 
method="post">
	 
<br>Name : <input type="text" name="yourname" value="">
<br>Email: <input type="text" name="email" size="30">
<br>Gender: <input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
<br>My Website Rating: 
<select name="Number">
<option value="0"SELECTED>SELECT</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<br>Comments: *Optional
<br><textarea cols="50" rows="8" name="Coments"></textarea>
<br><input type="submit" name="submit" value="Sign GuestBook">
<input type="Reset" name="Reset" value="Reset">
</form>
</Center>
</body>
</html>

thk's.