I use this code to replace not numeric character,but when the number is start with 0,like "000001111" or "0000000", 0 will appear in the front.
I want to replace the 0 start number,how to fix my code? When all the input is 0,like this "00000000",keep only one 0,when input number like this "000234",keep 234.
My code:
<input id="text_target_value" maxlength="11" class="text-right number" type="text" onkeyup="value=value.replace(/[^\d]/g,'')";">
I only want to fix onkeyup.
You don't need regular expression. just use Number function like in the below example;
function relpacing($this) {
$this.value = Number($this.value);
}
<input id="text_target_value" maxlength="11" class="text-right number" type="number" onkeyup="relpacing(this)">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With