Guest User

Untitled

a guest
Jul 23rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.52 KB | None | 0 0
  1. //זה במאסטר פייג
  2.   <script type="text/javascript">
  3.     function isEmpty(str)
  4.     {
  5.     return (str.length==0);
  6.     }
  7.    
  8.     function isValidString(str)
  9.     {
  10.         var badCharStr="$%^&*()_+[]{}<>&";
  11.         for (var i=0;i<str.length;i++)
  12.        {
  13.            for (var j=0;j<badCharStr.length;j++)
  14.            {
  15.                if (str.charAt(i)==badCharStr.charAt(j))
  16.                     return false;
  17.            }
  18.        }
  19.        if (str.indexOf("\"")!=-1)
  20.            return false;
  21.        return true;
  22.    }
  23.    function isValidNumber(str) {
  24.        for (var i = 0; i < str.length; i++) {
  25.            if ((str.charAt(i) > '9') || (str.charAt(i) < '0'))
  26.                return false;
  27.        }
  28.        return true;
  29.    }
  30.    
  31.    function isEmail(str)
  32.    {
  33.    
  34.    if ((str.split("@").length==2)&&
  35.       (str.indexOf("@")!=0)&&
  36.       (str.indexOf(".")!=0)&&
  37.       (str.lastIndexOf(".") != str.length - 1) &&
  38.       (str.indexOf(".")!=-1)&&
  39.       (str.length>=5) && (str.length<=30))
  40.           return true;
  41.     else
  42.        return false;
  43.     }
  44.  
  45.     </script>
  46.  
  47.  
  48. //זה ברגיסטר
  49. <script type="text/javascript">
  50. function checkForm()
  51. {
  52. var msg="";
  53. if (isEmpty(document.getElementById("uname").value))
  54. {
  55.     msg += "you must enter username\n";
  56. }
  57. else
  58. {
  59.     if (!(isValidString(document.getElementById("uname").value)))
  60.     {
  61.         msg += "you must enter valid characters in user name\n";
  62.     }
  63. }
  64.      
  65.       if (isEmpty(document.getElementById("fname").value))
  66.      {
  67.      msg+="you must enter first-name\n";
  68.      }
  69.  else {
  70.      if (!(isValidString(document.getElementById("fname").value))) {
  71.          msg += "you must enter valid characters in first name\n";
  72.      }
  73.  }
  74.  
  75.       if (isEmpty(document.getElementById("lname").value))
  76.      {
  77.      msg+="you must enter last-name\n";
  78.      }
  79.  else {
  80.      if (!(isValidString(document.getElementById("lname").value))) {
  81.          msg += "you must enter valid characters in last name\n";
  82.      }
  83.  }
  84.       if (isEmpty(document.getElementById("id").value))
  85.      {
  86.      msg+="you must enter id\n";
  87.      }
  88.  else {
  89.    
  90.      if (!(isValidNumber(document.getElementById("id").value)))
  91.      {
  92.      msg+="id must be only numbers\n";
  93.      }
  94.  }
  95.       if (isEmpty(document.getElementById("email").value))
  96.      {
  97.      msg+="you must enter email\n";
  98.      }
  99.  else
  100.  {
  101.       if (!isEmail(document.getElementById("email").value))
  102.       {
  103.           msg+="you must enter a valid email adress\n";
  104.       }
  105.        
  106.   }
  107.       if (isEmpty(document.getElementById("age").value))
  108.      {
  109.      msg+="you must enter age\n";
  110.      }
  111.  else {
  112.      if (!(isValidNumber(document.getElementById("age").value))) {
  113.          msg += "you must enter a number in age\n";
  114.      }
  115.  }
  116.      if (isEmpty(document.getElementById("city").value))
  117.      {
  118.      msg+="you must enter city\n";
  119.      }
  120.  
  121.      if (isEmpty(document.getElementById("gender").value))
  122.      {
  123.      msg+="you must enter gender\n";
  124.      }
  125.      
  126.      if (isEmpty(document.getElementById("pass").value))
  127.      {        
  128.      msg+="you must enter password\n";
  129.      }
  130.      
  131.      if (isEmpty(document.getElementById("repass").value))
  132.      {
  133.      msg+="you must repeat password\n";
  134.      }
  135.      else
  136.      {
  137.      if ((document.getElementById("pass").value)!=(document.getElementById("repass").value))
  138.      {
  139.      msg+="passwords are not the same\n";
  140.      }
  141.      }
  142.      if (msg.length!=0)
  143.      {
  144.           alert(msg);
  145.           return false;
  146.      }
  147.  return true;
  148. }
  149.  
  150. </script>
Add Comment
Please, Sign In to add comment