Hi, i have a form whereby people select values via radio buttons. I can’t seem to validate it before submitting the values into my php file ready to be written to my C2.txt file. The following code is my form1.html file:
[CODE]
<html>
<head>
<title> form 1</title>
<script language=”JavaScript”>
<!–
function validate_radio(frm)
{
alert(“inside function”);
var i;
for(i=0; i < document.form1.select[i].length; i++) // enter for loop, if i is less than the number of radio b
uttons, increment i
{
if (document.form1.select[i].checked)
{
return true;
}
else
{
alert(“You did not select a value”);
return false;
}
}
}
–>
</script>
</head>
<body>
<center>
<form name = “form1″ method=”post” action=”handler4.php”>
Mr.X <input type=”radio” name=”select” value=”Mr.X “> <br />
Tom Cruis <input type=”radio” name=”select” value=”Tom Cruis ” ><br />
<input type=”submit” name=”submit” value=”send” onClick=”return validate_radio(form1)”;>
</form>
</center>
</body>
</html>
At the moment, when i press submit, it goes to my php file without validating it. Please can somebody tell me why and how to adjust it before going into my php file as this is very URGENT ?