62
rated 0 times
[
65]
[
3]
/ answers: 1 / hits: 45157
/ 12 Years ago, sat, november 3, 2012, 12:00:00
I have the following form:
<form name=survey1 action=add5up.php method=post onsubmit=return validateForm()>
<div id=question>Q1) My programme meets my expectations</div><br />
Always<INPUT TYPE = 'Radio' Name ='q1' value= 'a'>
Usually<INPUT TYPE = 'Radio' Name ='q1' value= 'b'>
Rarely<INPUT TYPE = 'Radio' Name ='q1' value= 'c'>
Never<INPUT TYPE = 'Radio' Name ='q1' value= 'd'>
<input type=submit value=addData />
</form>
I am trying to validate whether a Radio
button has been selected.
The code I am using:
<script type=text/javascript>
function validateForm()
{
if( document.forms[survey1][q1].checked)
{
return true;
}
else
{
alert('Please answer all questions');
return false;
}
}
</script>
This is not working. Any ideas?
More From » radio-button