Javascript not working on all inputs
<p>I got a script that manages which key is allowed to press and which not, everything works fine, but it works just for one input... so the first one!
How to keep it working for multiple inputs?</p>

<pre><code>First input &lt;input type="text" id="inputs" /&gt;&lt;br&gt;
Second input &lt;input type="text" id="inputs" /&gt;


&lt;script type='text/javascript'&gt;
    toHtmlNumericInput('inputs');
    // call this function with the id of the input textbox you want to be html-numeric-input
    // by default, decimal separator is '.', you can force to use comma with the second parameter = true
    function toHtmlNumericInput(inputElementId, useCommaAsDecimalSeparator) {
        var textbox = document.getElementById(inputElementId);
        // called when key is pressed
        // in keydown, we get the keyCode
        // in keyup, we get the input.value (including the charactor we've just typed
        textbox.addEventListener("keydown", function _OnNumericInputKeyDown(e) {
            var key = e.which || e.keyCode; // http://keycode.info/
            if (!e.shiftKey &amp;&amp; !e.altKey &amp;&amp; !e.ctrlKey &amp;&amp;
                // alphabet
                key &gt;= 65 &amp;&amp; key &lt;= 90 ||
                // spacebar
                key == 32) {
                e.preventDefault();
                return false;
            }
            if (!e.shiftKey &amp;&amp; !e.altKey &amp;&amp; !e.ctrlKey &amp;&amp;
                // numbers
                key &gt;= 48 &amp;&amp; key &lt;= 57 ||
                // Numeric keypad
                key &gt;= 96 &amp;&amp; key &lt;= 105 ||
                // allow: Ctrl+A
                (e.keyCode == 65 &amp;&amp; e.ctrlKey === true) ||
                // allow: Ctrl+C
                (key == 67 &amp;&amp; e.ctrlKey === true) ||
                // Allow: Ctrl+X
                (key == 88 &amp;&amp; e.ctrlKey === true) ||
                // allow: home, end, left, right
                (key &gt;= 35 &amp;&amp; key &lt;= 39) ||
                // Backspace and Tab and Enter
                key == 8 || key == 9 || key == 13 ||
                // Del and Ins
                key == 46 || key == 45) {
                return true;
            }
            var v = this.value; // v can be null, in case textbox is number and does not valid
            // if minus, dash 
            if (key == 109 || key == 189) {
                // if already has -, ignore the new one
                if (v[0] === '-') {
                    // console.log('return, already has - in the beginning');
                    return false;
                }
            }
            if (!e.shiftKey &amp;&amp; !e.altKey &amp;&amp; !e.ctrlKey &amp;&amp;
                // comma, period and numpad.dot
                key == 190 || key == 188 || key == 110) {
                // console.log('already having comma, period, dot', key);
                if (/[\.,]/.test(v)) {
                    // console.log('return, already has , . somewhere');
                    return false;
                }
            }
        });
        textbox.addEventListener("keyup", function _OnNumericInputKeyUp(e) {
            var v = this.value;
            if(false) {
            // if (+v) { 
                // this condition check if convert to number success, let it be
                // put this condition will have better performance
                // but I haven't test it with cultureInfo = comma decimal separator, so, to support both . and , as decimalSeparator, I remove this condition
                //                      "1000"  "10.9"  "1,000.9"   "011"   "10c"   "$10"
                //+str, str*1, str-0    1000    10.9    NaN         11      NaN     NaN
            } else if (v) {
                // refine the value

                // this replace also remove the -, we add it again if needed
                v = (v[0] === '-' ? '-' : '') + 
                    (useCommaAsDecimalSeparator ? 
                        v.replace(/[^0-9\,]/g, '') : 
                        v.replace(/[^0-9\.]/g, ''));

                // remove all decimalSeparator that have other decimalSeparator following. After this processing, only the last decimalSeparator is kept.
                if(useCommaAsDecimalSeparator){
                    v = v.replace(/,(?=(.*),)+/g, '');
                } else {
                    v = v.replace(/\.(?=(.*)\.)+/g, '');
                }
                this.value = v; // update value only if we changed it
            }
        });
    }
&lt;/script&gt;
</code></pre>

<p>For example 2 or 4 other fields or to apply it for every field that will be on a page :/, is it possible?</p>