By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,818 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,818 IT Pros & Developers. It's quick & easy.

how to join many functions into one function

P: 17
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function validateForm() {
  3.     var firstname = document.getElementById("text1").value;   
  4.     var surname    = document.getElementById("text2").value;
  5.     var email      = document.getElementById("text3").value;
  6.     var cellnumber = document.getElementById("text4").value;
  7.     var address    = documnet.getElementById("text5").value;
  8.     var cardnumber = document.getElementById("text6").value;
  9.     var date       = document.getElementById("text7").value;
  10.     }
  11.  
  12.    if (firstname == "") {
  13.     alert("Name must be filled out");
  14.     return false;}    
  15.  
  16.     if (surname == "") {
  17.     alert("Surname must be filled out");
  18.     return false; }
  19.  
  20.     if (isNaN(cellnumber)){  
  21.     alert("Enter Numeric value only");  
  22.     return false;  
  23.     }else{  
  24.     return true;  
  25.      } 
  26.  
  27.      if (isNaN(cardnumber)){  
  28.    alert("Enter Numeric value only");  
  29.    return false;    
  30.     }else{  
  31.    return true;  
  32.    }       
  33.  
  34.   {   
  35.    var atposition=x.indexOf("@");  
  36.    var dotposition=x.lastIndexOf(".");  
  37.    if (atposition<1 || dotposition<atposition+2 || dotposition+2>=x.length){  
  38.     alert("Please enter a valid e-mail address \n atpostion:"+atposition+"\n dotposition:"+dotposition);  
  39.   return false;  
  40.   }  
  41.  
  42.  
  43. </script>
1 Week Ago #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,318
please explain your issue in a way that a reader can follow it and tell what the posted code has to do with it.
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.