I am trying (if possible) to set required fields based on a specific value from radio button group. I have tried with my code below and it doesn’t work. The required fields work, but when I add the radioObject checked part, it does not work.
Any ideas?
Thanks!
<html>
<head>
<script type=”text/javascript”>
function validate_required(field,alerttxt)
{
if (radioObject[i].checked) {
value = radioObject[i].value.”list one”
break }
} return true;
{
with (field)
{
if (value==null||value==””)
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,”Email must be filled out!”)==false)
{email.focus();return false;}
}
{
if (validate_required(address,”Address must be filled out!”)==false)
{address.focus();return false;}
}
}
</script>
</head>
<body>
<form action=”submit.htm” onSubmit=”return validate_form(this)” method=”post”>
<p>List:
<input type=”radio” name=”radio” id=”list1″ value=”list one”>
<br>
List:
<input type=”radio” name=”radio” id=”list2″ value=”list two”>
<br>
List:
<input type=”radio” name=”radio” id=”list3″ value=”list three”>
</p>
<p>Email:
<input type=”text” name=”email” size=”30″>
</p>
<p>address:
<input type=”text” name=”address” size=”30″ id=”address”>
</p>
<p>
<input type=”submit” value=”Submit”>
</p>
</form>
</body>
</html>