Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow only certain characters

I'd like to block all characters from being inputed except 0-9,a-z,A-Z range only alphanumeric characters. So when someone types ! for examplee nothing is written into input. How can I do that?

like image 643
Gandalf StormCrow Avatar asked Sep 10 '26 18:09

Gandalf StormCrow


1 Answers

You need to write a function that listens for the onkeypress event for the form field, then check to see if the form contains any unwanted characters, and if it does, you update the field with those characters removed.

like image 134
Mitch Dempsey Avatar answered Sep 12 '26 08:09

Mitch Dempsey