Advertisement:

Author Topic: Sidebar search decimal point in price min - max  (Read 402 times)

Rudy78Web

  • Newbie
  • *
  • Posts: 15
Sidebar search decimal point in price min - max
« on: October 21, 2016, 07:13:59 pm »
How to add a point with two digits 00 on this script?
The price will all time ending on .00

<script type="text/javascript">
  $(document).ready(function()
    {
    $(".one_input").unwrap();
  });
</script>

<script>
$('#priceMin').keyup(function(event) {

  // skip for arrow keys
  if(event.which >= 37 && event.which <= 40){
   event.preventDefault();
  }

  $(this).val(function(index, value) {
      value = value.replace(/,/g,'');
      return numberWithCommas(value);
  });
});

function numberWithCommas(x) {
    var parts = x.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    return parts.join(".");
}
</script>

Thanks