Hi, I was wondering ife there is a way to limit an input in a way that it can accept only numbers, no signs (- + _:.,;/?) nor letters. But I don’t know were to start and it would be so helpful to learn this. If anyone could be kind to share a light, I’ll be verry thankful!
You an use regex to define the input pattern:
https://www.google.com/search?q=regex+digits+only+site:stackoverflow.com&sa=X&ved=2ahUKEwibm9H-pbvmAhWHHxQKHRZ-C6QQrQIoBDAAegQIBhAN&cshid=1576538144113433&biw=1680&bih=939
Cool, thank you! Will try and learn
hey jd, i was able to kinda make it work, however the problem is the result is a little different than i expected. You see, the regex seems to only “reject” the entry if its not in a pattern.
What I wanted was to be able to set a form input to do not even allow user to write characters that aren’t numbers. Like that kind of fields of phone number in sites that when you try to write a leter, nothing happens. Sorry for not being more specific before, and if its not possible, please would you let me know?!
@lucassmdesign so you can use an onKeyPress() listener. Inside put a short setTimeout() (10 ms are enough). Inside the setTimeout function, check the current input value, use regex to remove the non-digit character,s and reassign the processed value to the input element.