Search code examples
javajava-melwuit

how to make textfield to accept only alphabets in LWUIT?


I have created some TextFields. Now I have to set constraint to that TextField only alphabets..I don't know how to do that in LWUIT


Solution

  • Override validChar method, try

    TextField textField = new TextField(){
            public boolean validChar(String c) {
                if (((c.charAt(0) > 'a') && (c.charAt(0) < 'z')) || ((c.charAt(0) > 'A') && (c.charAt(0) < 'Z'))) {
                    return true;
                }
                return false;
            }
        };