regex number and dot

regex number and dot

Hello,

I have script 

  1. <script>
  2. jQuery(function($) {
  3.       $('#fname').bind("change keyup", function() {
  4. var val = $(this).val();
  5. var regex = /^\d+$/;
  6. if (val.match(regex)) {
  7.   $(this).css("background", "red");
  8.   val = val.replace(regex, "");
  9.   $(this).val(val);
  10. }
  11.       });
  12. });
  13. </script>
  14. <input type="text" id="fname" name="fname">
This works exactly the opposite of what I want. 

When wrote in the field, will not be allowed characters except numbers and dot once.

It's about writing price.

Thanks.