Custom Validation On Key Press For TextInput Fields

Where is this code and how did you put it there? Context is everything.