I need to create a notification when a user tries to enter a restricted character on a form. I currently have it set so that they cannot enter any special characters except a hyphen or an underscore. I used a jQuery function I found and it won't even show the character if it is limited.
Users have been confused though because there is no alert. I would like to let them know that the key they pressed is not cool.
So far I have been able to use document.getElementById to isolate the input. I think that I can use an event listener for keypress to identify the special characters but I am not sure how to create that function. Then I assume I will use an if statement to insert a new element or html to display the message if they press a not cool key.
Am I on the right track? Any guidance or suggestions are greatly appreciated. I hope everyone is having a wonderful day :)
Aucun commentaire:
Enregistrer un commentaire