how to join many functions into one function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zayn
    New Member
    • Sep 2019
    • 17

    #1

    how to join many functions into one function

    Code:
    <script>
    function validateForm() {
        var firstname = document.getElementById("text1").value;   
    	var surname    = document.getElementById("text2").value;
    	var email      = document.getElementById("text3").value;
    	var cellnumber = document.getElementById("text4").value;
    	var address    = documnet.getElementById("text5").value;
    	var cardnumber = document.getElementById("text6").value;
    	var date       = document.getElementById("text7").value;
    	}
    
       if (firstname == "") {
        alert("Name must be filled out");
        return false;}	
     
        if (surname == "") {
        alert("Surname must be filled out");
        return false; }
    
    	if (isNaN(cellnumber)){  
        alert("Enter Numeric value only");  
        return false;  
        }else{  
        return true;  
         } 
    
         if (isNaN(cardnumber)){  
       alert("Enter Numeric value only");  
       return false;    
        }else{  
       return true;  
       }  	 
    	  
      {   
       var atposition=x.indexOf("@");  
       var dotposition=x.lastIndexOf(".");  
       if (atposition<1 || dotposition<atposition+2 || dotposition+2>=x.length){  
        alert("Please enter a valid e-mail address \n atpostion:"+atposition+"\n dotposition:"+dotposition);  
      return false;  
      }  
    
    
    </script>
    Last edited by gits; Sep 6 '19, 05:56 PM. Reason: use code tags please!
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    please explain your issue in a way that a reader can follow it and tell what the posted code has to do with it.

    Comment

    Working...