If you just want ideas, then other than RegEx, you could first trim the string, then use str_split and compare each character using indexOf to see whether it's a letter (upper case or lower case), number or space. If it's neither, then chances are it's a special character. Alternatively, you could do the opposite in which you use str_split and indexOf but your comparison string looks only for special characters. Either way, I wouldn't try to do a real-time validation, in which it would check the keyCodes since you have to account for the fact a user may use a backspace key, number pad, other random keys, etc... .