un-validates when pressing submit

Discussion in 'JavaScript' started by samsung88, Aug 5, 2011.

  1. #1
    I have this code it works fine validates fine until i press submit and it fails can anyone tell me what i am missing   

    just a simple drop down box
    
    <tr> <td><label for="subject">Subject</label></td>
     <td><select name="subject" id="subject" value="<?=$_SESSION['post']['subject']?>" >  <option value="0" selected="selected">Choose</option> 
    <option value="Question">Question</option> 
    <option value="Business proposal">Business proposal</option> 
    <option value="Advertisement">Advertising</option> <option value="Complaint">Complaint</option> </select>
     </td> <td id="subjectInfo">Subject</td> </tr>
    
    HTML:
     With this javascript

    
    var subject = $("#subject"); 
    var subjectInfo = $("#subjectInfo"); 
    
     form.submit(function(){
     if(validateName() & validateEmail() & validateSubject() & validateName() & validateName()) 
     return true
    else 
    return false; }); 
    
     function validateSubject(){ 
    if(this.selectedIndex > 0) { 
    subjectInfo.text("Valid");
     subjectInfo.removeClass("error");
     return true; } 
     // Not valid
     else{ 
    subjectInfo.text("NOT valid"); 
    subjectInfo.addClass("error"); 
    return false;  } 
    }
    
    Code (markup):
     

     Again it works fine up until i press submit and it goes from valid to not valid! can anyone tell me what i am not seeing??
     
    Last edited: Aug 5, 2011
    samsung88, Aug 5, 2011 IP