anyone know javascript??

codeman0013

Active Member
Hey if anyone knows js i need some help with some verification my form has all it needs on it and shoudl work. This will verify up to the email and i just added that in and after i did it stops there now it wont do the checkboxes. If i take the email out it works again or if i take out the check box it works so i'm lost here is the code...

Code:
function validateInputs3()    {
    if (document.frmsignup.fielddate.value == "") {
        alert("Please enter the Date");
        document.frmsignup.fielddate.focus();
        return false;
    } else    if (document.frmsignup.fieldname.value == "") {
        alert("Please enter your Name");
        document.frmsignup.fieldname.focus();
        return false;
    } else    if (document.frmsignup.fieldfarmname.value == "") {
        alert("Please enter your Farm Name");
        document.frmsignup.fieldfarmname.focus();
        return false;
    } else    if (document.frmsignup.fieldspousename.value == "") {
        alert("Please enter your Spouses Name");
        document.frmsignup.fieldspousename.focus();
        return false;
    } else if (document.frmsignup.fieldaddress.value == "") {
        alert("Please enter your Address");
        document.frmsignup.fieldaddress.focus();
        return false;
    } else if (document.frmsignup.fieldcity.value == "") {
        alert("Please enter your City");
        document.frmsignup.fieldcity.focus();
        return false;
    } else if (document.frmsignup.fieldstate.value == "") {
        alert("Please enter your State");
        document.frmsignup.fieldstate.focus();
        return false;
    } else if (document.frmsignup.fieldzip.value == "") {
        alert("Please enter your Zip Code");
        document.frmsignup.fieldzip.focus();
        return false;
    } else if (isNaN(document.frmsignup.fieldzip.value) == true) {
        alert("Zip Code must be a 5 digit number");
        document.frmsignup.fieldzip .select();
        return false;
    } else if (document.frmsignup.fieldcounty.value == "") {
        alert("Please enter your County");
        document.frmsignup.fieldcounty.focus();
        return false;
    } else if (document.frmsignup.fieldphone.value == "") {
        alert("Please enter your Phone Number");
        document.frmsignup.fieldphone.focus();
        return false;
    }
    {var emailID=document.frmsignup.fieldemail
    
    if ((emailID.value==null)||(emailID.value=="")){
        alert("Please Enter A Correct Email Address")
        emailID.focus()
        return false
    }
    if (echeck(emailID.value)==false){
        emailID.value=""
        emailID.focus()
        return false
    }
    return true
    }
    {var Ckfieldoccupation = false;
 for (var i=0; i < document.frmsignup.fieldoccupation.length; i++) {
  if (document.frmsignup.fieldoccupation[i].checked) {
   Ckfieldoccupation = true;
  }
 }
 if (!Ckfieldoccupation){
  alert('You must select at least one of the occupations');
  return false;
 }
 return true;
}
    
    
    }
 
You're code is a bit malformed at the bototm. I cleaned it up a bit, try this (untested, but might get you somewhere).

Code:
function validateInputs3() {
    if (document.frmsignup.fielddate.value == "") {
        alert("Please enter the Date");
        document.frmsignup.fielddate.focus();
        return false;
    } else if (document.frmsignup.fieldname.value == "") {
        alert("Please enter your Name");
        document.frmsignup.fieldname.focus();
        return false;
    } else if (document.frmsignup.fieldfarmname.value == "") {
        alert("Please enter your Farm Name");
        document.frmsignup.fieldfarmname.focus();
        return false;
    } else if (document.frmsignup.fieldspousename.value == "") {
        alert("Please enter your Spouses Name");
        document.frmsignup.fieldspousename.focus();
        return false;
    } else if (document.frmsignup.fieldaddress.value == "") {
        alert("Please enter your Address");
        document.frmsignup.fieldaddress.focus();
        return false;
    } else if (document.frmsignup.fieldcity.value == "") {
        alert("Please enter your City");
        document.frmsignup.fieldcity.focus();
        return false;
    } else if (document.frmsignup.fieldstate.value == "") {
        alert("Please enter your State");
        document.frmsignup.fieldstate.focus();
        return false;
    } else if (document.frmsignup.fieldzip.value == "") {
        alert("Please enter your Zip Code");
        document.frmsignup.fieldzip.focus();
        return false;
    } else if (isNaN(document.frmsignup.fieldzip.value) == true) {
        alert("Zip Code must be a 5 digit number");
        document.frmsignup.fieldzip .select();
        return false;
    } else if (document.frmsignup.fieldcounty.value == "") {
        alert("Please enter your County");
        document.frmsignup.fieldcounty.focus();
        return false;
    } else if (document.frmsignup.fieldphone.value == "") {
        alert("Please enter your Phone Number");
        document.frmsignup.fieldphone.focus();
        return false;
    } else if (document.frmsignup.fieldemail == "") {
        alert("Please enter a correct Email Address");
        document.frmsignup.fieldemail.focus();
        return false;
    }
    
    var Ckfieldoccupation = false;
    for (var i=0; i < document.frmsignup.fieldoccupation.length; i++) {
        if (document.frmsignup.fieldoccupation[i].checked) {
            Ckfieldoccupation = true;
        }
    }

    if (!Ckfieldoccupation){
        alert('You must select at least one of the occupations');
        return false;
    }

    return true;
}
 
Back
Top