Hi I have a form with a question that must be answered Before the form is submitted. There are 4 possible answers to the question 3 radio buttons and 1 text field.
If none of the radio buttons are selected then the text field must be populated BEFORE the form can be submitted.
validating that one of the radio buttons are selected is no problem, however; verifying that the text box is populated is driving me nuts.
Here is my current code. I have commented out (//) the line I was trying to use to check for the text box being populated if no radio buttons were checked. tia
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859">
<style>
body{cursor:crosshair,color:red;}
</style>
<script language="JavaScript">
function RadioCheck(){
csfOs=classSurFrm.other_22.value;
itok1=false;
for(it=0; it< classSurFrm.ITEM_19.length;it++){
if(classSurFrm.ITEM_19[it].checked)itok1=true;
//if(csfOs=="" && itok1=="false"
}
if(!itok1){
alert('You must answer #19. Please try again');
event.returnValue=false;
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="classSurFrm" ACTION='success.html' METHOD='POST'onSubmit="RadioCheck();">
<div align="center">
<table width="50%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Manager">
Manager </td>
</tr>
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Co-Worker">
Co-worker </td>
</tr>
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Website">
Website </td>
</tr>
<tr>
<td valign="middle">Other source:
<input type="text" name="other_22" size="30">
</td>
</tr>
</table>
</div>
<input type="submit" name="Submit" value="Submit"><input type="Reset" name="Reset" value="Reset">
</form>
</body>
</html>
If none of the radio buttons are selected then the text field must be populated BEFORE the form can be submitted.
validating that one of the radio buttons are selected is no problem, however; verifying that the text box is populated is driving me nuts.
Here is my current code. I have commented out (//) the line I was trying to use to check for the text box being populated if no radio buttons were checked. tia
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859">
<style>
body{cursor:crosshair,color:red;}
</style>
<script language="JavaScript">
function RadioCheck(){
csfOs=classSurFrm.other_22.value;
itok1=false;
for(it=0; it< classSurFrm.ITEM_19.length;it++){
if(classSurFrm.ITEM_19[it].checked)itok1=true;
//if(csfOs=="" && itok1=="false"
}
if(!itok1){
alert('You must answer #19. Please try again');
event.returnValue=false;
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="classSurFrm" ACTION='success.html' METHOD='POST'onSubmit="RadioCheck();">
<div align="center">
<table width="50%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Manager">
Manager </td>
</tr>
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Co-Worker">
Co-worker </td>
</tr>
<tr>
<td>
<input type="radio" name="ITEM_19" value="ITEM_19|Website">
Website </td>
</tr>
<tr>
<td valign="middle">Other source:
<input type="text" name="other_22" size="30">
</td>
</tr>
</table>
</div>
<input type="submit" name="Submit" value="Submit"><input type="Reset" name="Reset" value="Reset">
</form>
</body>
</html>