Use a DocumentFilter
to filter the values going to a text component in real time, that's what it's design for. Take a look at these examples, there's even a PatternFilter
for using with regular expressions...
For post validation, use a InputVerifier