peter butler
01-06-2004, 11:42 AM
only the first radio button validates. when you select the second radio button, the form bypasses the validation and i cant see why?
<html>
<head>
<script type="text/javascript">
function radioCheck(elm)
button has been selected
{
var checked = document.forms["registration"].elements[""];
element and created a variable
var count;
//new variable called count
for (count=0; count<4; count++)
//a loop to check the status of all radio buttons.
{
//the loop starts at 0 then increments by 1 each time
if (elm[count].checked)
return true;
//if a radio has been checked the function returns true
else return false;
//if no radio checked the function returns false
}
}
function isReady (form)
{
if(radioCheck(form.title)==false)
{
alert("Please give us your title")
return false;
}
else return true;
}
</script>
</head>
<body>
<form id="signInForm" method="post" onsubmit="return isReady(this)" name="registration" action="#">
<input id="titleMr" name="title" type="radio">
<input id="titleMrs" name="title" type="radio">
<input id="titleMiss" name="title" type="radio">
<input id="titleMs" name="title" type="radio">
<input id="reset" type="reset" value="reset">
<input id="next" type="submit" value="Next">
</body>
</html>
<html>
<head>
<script type="text/javascript">
function radioCheck(elm)
button has been selected
{
var checked = document.forms["registration"].elements[""];
element and created a variable
var count;
//new variable called count
for (count=0; count<4; count++)
//a loop to check the status of all radio buttons.
{
//the loop starts at 0 then increments by 1 each time
if (elm[count].checked)
return true;
//if a radio has been checked the function returns true
else return false;
//if no radio checked the function returns false
}
}
function isReady (form)
{
if(radioCheck(form.title)==false)
{
alert("Please give us your title")
return false;
}
else return true;
}
</script>
</head>
<body>
<form id="signInForm" method="post" onsubmit="return isReady(this)" name="registration" action="#">
<input id="titleMr" name="title" type="radio">
<input id="titleMrs" name="title" type="radio">
<input id="titleMiss" name="title" type="radio">
<input id="titleMs" name="title" type="radio">
<input id="reset" type="reset" value="reset">
<input id="next" type="submit" value="Next">
</body>
</html>