i need some help.
I'm using keyup to format the currency, but when the value reach 1000 or more the .change doesn't work. If i remove the toLocaleString(), the .change works. How can i make both function work? Thank you.
FYI i'm using laravel.
$("#amount").change((event) => {
updateAmountInfo($('#amount').val())
})
// End of Check Balance and Amount //
$("#amount").on("keyup", function(event) {
checkBalance();
var selection = window.getSelection().toString();
if ($.inArray(event.keyCode, [38, 40, 37, 39]) !== -1) {
return;
}
var $this = $(this);
var value = $this.val();
var input = value.replace(/[\D\s\._\-]+/g, "");
input = input ? Number(input) : 0;
$this.val(function() {
return (input === 0) ? "" : input.toLocaleString("en-US");
});
});