M
Matt
The following code is try to validate if the user selects a radio button
choice. I dont understand why document.UserInputs.question.value; gets
undefined value even user make a choice. I tried text box and drop down
list, and it works fine.
<html>
<head>
<script type="text/javascript">
function CheckForm()
{
var radiochoice = document.UserInputs.question.value;
document.write("choice = " + radiochoice);
if(radiochoice != "yes" && radiochoice != "no")
{
alert("Choose the radio button");
document.UserInputs.radiogroup.focus();
return false;
}
document.UserInputs.submit();
}
</script>
</head>
<body>
<form action="formtestprocess.asp" name="UserInputs" method="post"
onsubmit="return CheckForm()">
<P>Yes<input type="radio" name="question" value="yes">
No<input type="radio" name="question" value="no">
<P><input type="submit" name="submitbutton" value="submit here">
<input type="reset" name="resetbutton" value="reset here">
</form>
</body>
</html>
Please advise. Thanks!
choice. I dont understand why document.UserInputs.question.value; gets
undefined value even user make a choice. I tried text box and drop down
list, and it works fine.
<html>
<head>
<script type="text/javascript">
function CheckForm()
{
var radiochoice = document.UserInputs.question.value;
document.write("choice = " + radiochoice);
if(radiochoice != "yes" && radiochoice != "no")
{
alert("Choose the radio button");
document.UserInputs.radiogroup.focus();
return false;
}
document.UserInputs.submit();
}
</script>
</head>
<body>
<form action="formtestprocess.asp" name="UserInputs" method="post"
onsubmit="return CheckForm()">
<P>Yes<input type="radio" name="question" value="yes">
No<input type="radio" name="question" value="no">
<P><input type="submit" name="submitbutton" value="submit here">
<input type="reset" name="resetbutton" value="reset here">
</form>
</body>
</html>
Please advise. Thanks!