But in fact, if the user set the #prc input to 50.345.34, the try & lt = = prc condition always returns true.
Pretty sure the observation error. Your prc is a string that will then be implicitly converted to a number by the <= operator. The number will be NaN , because "50.345.34" cannot be implicitly converted, and relationships using NaN never true.
However, in reality this does not change what you want to do, which converts prc to a number with a goal and checks the result:
var intervalId; function randomize(){ var prc = +$("#prc").val();
I should note that the above can do what you do not need if the input is empty: it will use the value 0 , because +"" - 0 . If you do not want this, you can do this:
var prcString = $.trim($("#prc").val()); var prc = +prcString; if (!prcString) {
source share