This will allow the user to only enter alphabets and numerics if they enter a special character they will be thrown an error message or an alert.
- Add ID to the form in your HTML
- Add ID to the input in your HTML
This is an example of the input and form tags
You can test this code in our Online HTML Compiler and if you try to enter a special character it will alert you with a message you can show any message to the user.
I have used regex for this validation I hope you found this guide useful and helpful if you want more guides like this do stay with us by
- SUBSCRIBING TO OUR NEWSLETTER GO BELOW OR
- JOINING OUR TELEGRAM CHANNEL HERE – JOIN TELEGRAM CHANNEL
Thank you for reading, Have a nice day 🙂