title: code does not validate email from a form, in javascpricpt
body: <p>hi i font know if this is the right place to ask this question but i have a problem with my code that i cannot figure out. i have tried many different algorithms and none work. i am trying to validate email from a form.
  here is the code (form is in html)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function isValidString(str) {
  
    var quot = "\"";
    if (str.indexOf(quot) != -1)
      return false;
  
    var badStr = "$%^&amp;*()_+[]{}&lt;&gt;?אבגדהוזחטיכךלמםנןסעפצקרשת";
    var i = 0,
      p;
    while (i &lt; str.length) {
      p = badStr.indexOf(str.charAt(i));
      if (p != -1)
        return false;
      i++;
    }
  
  
    return true;
  }
  
  function isValidEmail()
  
  {
  
    var str = document.getElementById("email").value;
  
    document.write("email from isValidEmail(str) = " + email);
    if (isEmpty(str) || str.length &lt; 5) {
      alert("isEmpty(str) || str.length &lt; 5 = false");
      return false;
    }
  
    if (!isValidString(str)) {
      alert("!isValidString(str) = false");
      return false;
    }
  
    var atSign = str.indexOf('@');
    if (atSign == -1 || str.lastIndexOf('@') || atSign === 0 || atSign == str.length - 1) {
      alert("atSign == -1 || str.lastIndexOf('@') || atSign == 0 || atSign == str.length - 1 = false");
      return false;
    }
  
    var dotSign = str.indexOf('.', atSign);
    if (dotSign == -1 || dotSign === 0 || dotSign == str.length - 1 || dotSign - atSign &lt; 2) {
      alert("dotSign == -1 || dotSign == 0 || dotSign == str.length - 1 || dotSign - atSign &lt; 2 = false");
      return false;
    }
    return true;
    
    </code></pre>
  </div>
  </div>
  </p>
  
  <p>no matter what i input it always comes back valid.
  here is the part where i apply it:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var email = document.getElementById("email").value;
  if (emailcheck(email)) {
    alert("invalid email");
    return false;
  }
  
  return true;</code></pre>
  </div>
  </div>
  </p>
  
  <p>thanks in advance</p>