Here is my code first of all,
$(function() {
var fee_percent = parseFloat('<?php echo $gateway["gateway_fees"]; ?>');
var fee_fixed = parseFloat('<?php echo $gateway["gateway_fixed_fees"]; ?>');
var min = parseFloat('<?php echo $gateway["min_invest_limit"]; ?>');
var max = parseFloat('<?php echo $gateway["max_invest_limit"]; ?>');
$("#amountId").on('change keyup keydown', function() {
var $this = $(this);
var val = parseFloat($this.val());
val = val.toFixed(5);
var valid = true;
var fee = parseFloat(val * fee_percent / 100) + fee_fixed;
fee = fee.toFixed(5);
var final_amount = val - fee;
final_amount = final_amount.toFixed(5);
console.log("value: " + val);
console.log("fee: " + fee);
console.log("final: " + final_amount);
console.log("min: " + min.toFixed(5));
console.log("max: " + max.toFixed(5));
if(val <= 0 || isNaN(val) || fee > val || val < min.toFixed(5) || val > max.toFixed(5)) fee = final_amount = 0;
$("#depositFee").html(fee);
$("#depositAmountFinal").html(final_amount);
});
});
and now my problem is,
val > max.toFixed(5) this is always returning TRUE.
Here is the console response :
value: 11.00000 fee: 0.46000 final: 10.54000 min: 10.00000 max: 10000.00000
so the value is 11 and max value in 10000, then why its false ?
If its not clear, please ask, thanks.
UPDATE : when I type 10, 100, or 1000 and so on, it works fine.
If I don't use max.toFixed(5) but instead I use only max, everything works fine but when I type some value with 5 in the end, like 55, 65, 75 and so on, the condition become true again, that should return false.
"11" > "10000":-)fee = final_amount = 0;, this is from that if condition block, so if value is 11 and max is 10000,fee = final_amount = 0;should run or no ? According to me, NO, but actually it runs, that's my problem.