mlopezco
02-11-2004, 12:37 PM
Hi. I am a newbie here, so please be nice
I can't figure out why my function isn't working. I am listing the code below, and if anyone can help or has other suggestions, please let me know! - Thanks!!!!!
<head>
<script language="JavaScript" type="text/JavaScript">
function validRadio(formField[i], fieldLabel, num) {
var result = true;
for (i=0, i<num, i++) {
if (!(formField[i].checked)) {
alert('Please select an answer for "' + fieldLabel + '".');
formField.focus();
result = false;
}
}
return result;
}
function validateForm(orientation){
if (!validRadio(orientation.enroll[],"Enrollment Time",3))
return false;
if (!validRadio(orientation.BFscholar[],"Bright Futures recipient",2))
return false;
if (!validRadio(orientation.prog[],"participation in special USF programs",2))
return false;
return true;
}
<FORM id="orientation" name="orientation" method="post" onSubmit="return validateForm(this)" action="mailto:handle@domain.com">
<br>
<input type="radio" name="enroll" id="enroll" value="less">Less than half time (1 - 5 credit hours)
<br>
<input type="radio" name="enroll" id="enroll" value="half">At least half time (6 - 11 credit hours)
<br>
<input type="radio" name="enroll" id="enroll" value="full">Full time (12 or more credit hours)</span>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="body">
<td width="25%"><input type="radio" name="BFscholar" id="BFscholar" value="yes">Yes</td>
<td width="25%"><input type="radio" name="BFscholar" id="BFscholar" value="no">No</td>
<td width="50%"> </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="body">
<td width="25%"><input type="radio" name="prog" id="prog" value="yes">Yes</td>
<td width="25%"><input type="radio" name="prog" id="prog" value="no">No</td>
<td width="50%"> </td>
</tr>
</table>
I can't figure out why my function isn't working. I am listing the code below, and if anyone can help or has other suggestions, please let me know! - Thanks!!!!!
<head>
<script language="JavaScript" type="text/JavaScript">
function validRadio(formField[i], fieldLabel, num) {
var result = true;
for (i=0, i<num, i++) {
if (!(formField[i].checked)) {
alert('Please select an answer for "' + fieldLabel + '".');
formField.focus();
result = false;
}
}
return result;
}
function validateForm(orientation){
if (!validRadio(orientation.enroll[],"Enrollment Time",3))
return false;
if (!validRadio(orientation.BFscholar[],"Bright Futures recipient",2))
return false;
if (!validRadio(orientation.prog[],"participation in special USF programs",2))
return false;
return true;
}
<FORM id="orientation" name="orientation" method="post" onSubmit="return validateForm(this)" action="mailto:handle@domain.com">
<br>
<input type="radio" name="enroll" id="enroll" value="less">Less than half time (1 - 5 credit hours)
<br>
<input type="radio" name="enroll" id="enroll" value="half">At least half time (6 - 11 credit hours)
<br>
<input type="radio" name="enroll" id="enroll" value="full">Full time (12 or more credit hours)</span>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="body">
<td width="25%"><input type="radio" name="BFscholar" id="BFscholar" value="yes">Yes</td>
<td width="25%"><input type="radio" name="BFscholar" id="BFscholar" value="no">No</td>
<td width="50%"> </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="body">
<td width="25%"><input type="radio" name="prog" id="prog" value="yes">Yes</td>
<td width="25%"><input type="radio" name="prog" id="prog" value="no">No</td>
<td width="50%"> </td>
</tr>
</table>
