title: simple input field validation
body: <p>I am trying simple textarea validation with <code>regex pattern</code>(it should allow only numbers.characters,comma,space and dot).But its not working.<br>If I click <code>click button</code> without values,Directly its showing <code>alert()</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
    $("#sub").click(function(){
      debugger
      var a=$('.showReason' ).val();
      alert(a)
      var regex=/^[a-zA-Z0-9.]+$/;
      if(!regex.test(a)==false){
     $('.showReason' ).addClass('box');
      } else {
        alert("gud");
      }
    });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.box{
  border:2px solid red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;textarea name="" class="showReason col-xs-12 form-control required" &gt;&lt;/textarea&gt;
   &lt;button id="sub"&gt;
   click
   &lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>