T
T
Toster7772018-02-24 22:52:28
JavaScript
Toster777, 2018-02-24 22:52:28

The calculator does not accept numbers with a ten, how to fix it?

Hello. There is one sports calculator:

$(document).ready(function() {

  $(".submits").keyup(function(enter) {
    if (enter.keyCode == 13) { //enter
      wilks();
    }
  });

  $("#findValue").click(function(enter) {
    enter.preventDefault();
    wilks();
  });
});

var bodyweight = $('#bodyweight').val(); 

  var liftedweight = $('#liftedweight').val();

I cannot enter numbers with a decimal remainder in these two fields, the calculator gives an error.
Those. I enter the integer 100 everything is ok, but 100.25 is not ok.
How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antonio Solo, 2018-02-24
@solotony

100.25 - not a number
so that there are no errors, use

replace(',' , '.' );
parseInt
parseFloat

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question