title: Regex for a valid numeric with optional commas & dot
body: <p>i am trying only to allow numerals and special chars like '.' and ',' to be allowed in my text string. for that i have tried following code </p>
  
  <pre><code>var pattern = /[A-Za-z]/g;
  var nospecial=/[\(#\$\%_+~=*!|\":&lt;&gt;[\]{}`\\)';@&amp;?$]/g;
  if (!ev.ctrlKey &amp;&amp; charCode!=9 &amp;&amp; charCode!=8 &amp;&amp; charCode!=36 &amp;&amp; charCode!=37 &amp;&amp; charCode!=38 &amp;&amp; (charCode!=39 || (charCode==39 &amp;&amp; text=="'")) &amp;&amp; charCode!=40) {
      console.log(text);
      if (!pattern.test(text) &amp;&amp; !nospecial.test(text)) {
          console.log('if');
          return true;
      } else {
          console.log('else');
          return false;
      }
  }
  </code></pre>
  
  <p>but not getting the desired output. tell me where i am wrong.</p>