title: name Validation, logical error related to Regex
body: <pre><code>function validator()
  {
  var f = document.forms.suform.elements.fn.value;
  if(f==null || f=="" || f==" ") //condition 1
  {
      alert("First name is required!");
      return false;
  }
  else if(!(/^[a-zA-Z ]{2,30}$/,test(f))) // condition 2
  {
      alert('Invalid First Name');
      return false;
  }
      //Some other conditions
  }
  </code></pre>
  
  <p><strong>I called it as</strong></p>
  
  <pre><code>&lt;form method="post" name="suform" onsubmit="return validator()" action="register.php"&gt;
  &lt;input placeholder="First Name" name="fn" type="text" id="fname" maxlength=20&gt;
      //other inputs
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Now the problem is condition 2 is not working and as long as it is there the conditions below it also dont work,
  the second i delete condition 2 everything starts running fine.
  There is some error in regex checking.</strong></p>