14 Answers
New Answeroninput is when you do something related to the input. onkeyup is when you pressed a key on your keyboard. So onkeydown is when you stopped pressing the key.
Pepe the Hacker see my code 9 challenges, I did it : https://code.sololearn.com/W6mVdUoF5wF4/?ref=app here is what I did and what you want : <input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" id="entry" placeholder="Enter a number" maxlength="15"/> this is for allow only numbers. so change the regex by yours !
the () ? it's included on my lesson ^^ it's to group what you want, and you can recall it with $1 (with " ") for example string.replace(/hi (nox)/, "hello $1"); here $1 = nox and you can have multiple $ thanks multiple ()
Learn Playing. Play Learning
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message