How to enable input for only specific characters?

Since I cannot mark comments as accepted answers, for administrative purposes I will put this comment and mark thread as solved. For future answer-seekers, see comments below for the suggestions that have been given!