We want to restrict certain characters in the Project and Task fields for export purposes.
I would say "regular expressions by means of an API", but I'm not sure you are talking on 2E or Plex.
look at masks to do simple restriction.
secondly I have used on update event which if i remember correctly fires on each key stroke to as opposed to modifed event (may be the other way round) and then check if the last entered character satisfys your criteria.
Done both in stellatools if you care to look up.