Reputation: 12892
The HTML:
<input id="example" type="number"/>
The JS:
$("#example").on("input", function (e) {
debugger;
});
The issue is as follows. If the content of the field is 1000
, and the user enters a decimal (.
), to make it 1000.
, it does not fire the input
event in Chrome. Is this normal, and if so, then how can I make it fire an event to be able to detect it?
Upvotes: 0
Views: 664
Reputation: 6237
As mentioned in previous comment, the problem is that a number with dot "." in the end doesn't passed in. So here is something you can do:
$(function(){
var lastNum;
$("#example").on("input", function (e) {
if(this.value.length>0)lastNum=this.value;//if value passed in correctly - update it
console.debug(lastNum);//Do anything with the lastNum
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="example" type="number"/>
Upvotes: 1