I have a text input field, where I am checking each click, so the user should enter only numbers. I need to do it with javascript.
I created this in my function:
result = number.replace(/\D/g, '');return result;
I also tried result = number.replace(/[^0-9.\-]/g, '');return result;
This is working, so it doesn't allow to enter anything except numbers, BUT if I press any letter twice (gg or aa,...) then one of the letters is showing in input field.
If I enter different letters (ab, gh,...), then it is ok, it doesn't allow any letter. It happens only if I press the same letter twice.
Not sure why it is happening, as the regexp should allow only numbers.