title: Javascript function need allow numbers, dot and comma
body: <p>I need to create a function to allow numbers dot and comma. So anyone corrects the following function</p>
  
  <pre><code>function on(evt) {
    var theEvent = evt || window.event;
    var key = theEvent.keyCode || theEvent.which;
    key = String.fromCharCode( key );
    var regex = /[0-9]|\./;
    if( !regex.test(key) ) {
      theEvent.returnValue = false;
      if(theEvent.preventDefault) theEvent.preventDefault();
    }
  }
  </code></pre>