How to use multiplate onkeyup input?

I have this input, I want use 2 onkeyup in one input, How use it?

My input:

<input type="text" onkeyup="onInputChange(this)" onkeyup="separateNum(this.value,this);">

My First onkeyup scrept:

<script>
        function separateNum(value, input) {
                /* seprate number input 3 number */
                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;
                }
            }
</script>

My secend onkeyup scrept:

<script>
function onInputChange(e) {
  const span = document.getElementById('result');
  span.innerHTML = Math.floor(e.value / 10);
}
</script>

11 thoughts on “How to use multiplate onkeyup input?”

Leave a Comment