In the below code I need to set a minus number for the text even when the user types a positive value. That is working fine.
However it doesn't allow me to enter a floating-point value. When I try to enter the decimal point from the keyboard it will not allow it. That is because I am taking the absolute value.
Does anyone know how to figure this out? A user should be able to enter a floating-point value as well such as 34.50. Where have I gone wrong and how should I correct this?
$('#loss').bind("keyup blur", function() {
var a = Math.abs(Number($(this).val()));
var c = a * -1;
$('#loss').val(c);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="loss" type="text" placeholder="type" style="border: none; text-align: center;" class="amt_num_box_reduce_space">