Copy from TOTextInputChecker at code4app.com