I have this input, I want use 2 onkeyup in one input, How use it?
I want sepret my number 3 number with comma and I want my input value of a factor of 10 too.
For example, if the user enters the number 100214, the user will immediately see the number 10021 (No decimal) in span result and see the number 100,214 in input.
function separateNum(value, input) {
var nStr = value + '';
nStr = nStr.replace(/\,/g, "");
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
if (input !== undefined) {
input.value = x1 + x2;
} else {
return x1 + x2;
}
}
function onInputChange(e) {
const span = document.getElementById('result');
span.innerHTML = Math.floor(e.value / 10);
}
<input type="text" onkeyup="onInputChange(this); separateNum(this.value,this);">
<span id='result'>please enter number</span>