Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Validation Form - Radio (help)
Old 02-11-2004, 02:17 PM Validation Form - Radio (help)
Junior Talker

Posts: 1
Location: Tampa Bay, FL - USA
Trades: 0
Hi,

I am working validating an HTML form using Javascript. I wrote a function to validate radio groups and it doesn't seem to be working. I can tell, because the alert message should pop up if I leave the group unchecked.

I am attaching the code - Any help is appreciated.

<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;
}
</script></head>


</body>
<FORM id="orientation" name="orientation" method="post" onSubmit="return validateForm(this)" action="name@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)


<input type="radio" name="BFscholar" id="BFscholar" value="yes">Yes</td>

<input type="radio" name="BFscholar" id="BFscholar" value="no">No</td>


<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>

</form></body>
mlopezco is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Validation Form - Radio (help)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08167 seconds with 12 queries