To limit the length of a text field we use the Method setMaxLength(int maxLength).
It works fine with normal letters or numbers.

But if you enter a % to the last position, the limit of the TextField lifted and you can enter more characters.