FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Restrict Text Input Characters HTML JavaScript Tutorial

Published :
Author :
Adam Khoury

Learn to restrict one or more text fields in a form to allow only characters that you desire to be typed into them. We will remove undesirable characters in real time as the user types.

<script> function lettersOnly(input) { var regex = /[^a-z]/gi; input.value = input.value.replace(regex, ""); } </script> <input id="firstname" placeholder="first name" onkeyup="lettersOnly(this)"> <input id="lastname" placeholder="last name" onkeyup="lettersOnly(this)">