#Validate a textfield

1 messages · Page 1 of 1 (latest)

short tapir
#

I want a textfield only to take only letters as input and no numbers. Also i have to use a input verifier how can i achieve that? i have only found on docs on how to verify for a specific word... Also since JTextfield only takes strings i dont know how to make it only accept letters and no numbers.

public class verfifyForLetterOnly extends InputVerifier {

    @Override
    public boolean verify(JComponent input) {
        JTextField tf = (JTextField) input;
        if (    ) {
            
        }
        return ;
        
    }

}
rotund hingeBOT
#

<@&987246487241105418> please have a look, thanks.

rotund hingeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

winter sage
#

I would use a DocumentFilter but I don't know if that is the best way to do it.

celest tinsel
#

i would just place a regex on the check or ( depending on the gui ), set the limits