combining functions - 10/14/2007 10:34:35
I want to combine these 2 functions so that I can use 1 onSubmit handler. How can I do that?
First Function:
<script language="JavaScript">
function validate2(){
var radios = document.getElementsByName("type");
var sel_value = null;
for(i=0; i<radios.length; i++) {
if(radios.checked)
sel_value = radios.value;
}
if(sel_value == "Other" && document.getElementById("other_type").value == "") {
alert("Please specify an other type.");
document.FrontPage_Form1.other_type.focus();
return false;
}
return true;
}
</script>
Second Function:
<script language="JavaScript">
function validate1(){
ICOK=false;
for (ic=0;ic<6;ic++) {
if (FrontPage_Form1.type[ic].checked) return true;
}
if (!ICOK) {
alert('The Client Feedback Type is required. Please select One.');
return false;
}
}
</script>
When I try, only the first function runs, not both. What is happening is there are 6 radio buttons. One is an "other" selection that needs a text field entered. So first I want to validate that at least one radio is selected and then if other is selected, that the other text field is filled in. They work independantly. Thanks