javascript validation for one of several drop down boxes

B

barn104_1999

I have a form with 7 drop down boxes, and I need to write a script that
will make sure that at least one is selected.
Here is what I currently have, although I'm a little stumped as to
where to go next (I've only listed the script to one of the dropdowns,
as the rest were commented out anyway). Thanks:


function checkNorman_session_Tuesday_June_6th(choice){
var count1=0;
var error = "";
if (choice ==0){
count1=0;
}else {count1 += 1;
}
return error;
}


function checkClassSession(choice) {
var error = "";
var count_total = count1;
if (count_total == 0) {
error = "Please choose a class session from the drop-down
list.\n\n";
}
if (count_total > 1) {
error = "Please select only one class session from the drop-down
lists.\n\n";
}
return error;
}

<!-- Begin check form script, which refers to "validate.js" code,
listed above -->
<!--
function checkWholeForm(theForm) {
var why = "";

why += checkLastName(theForm.last_name.value);
why += checkFirstName(theForm.first_name.value);
why += checkDepartment(theForm.department.value);
why += checkEmail(theForm.email.value);
why += checkPhone(theForm.phone.value);
/*why += checkClassSession(value);*/
/*why +=
checkNorman_session_Tuesday_June_6th(theForm.Norman_session_Tuesday_June_6th.selectedIndex);*/
/*why += checkClassSession(theForm.class_session.selectedIndex);*/
if (why != "") {
alert(why);
return false;
}
return true;
}
// -->
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top