0

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

Mun0n
  • 4,438
  • 4
  • 28
  • 46
Juhi
  • 85
  • 7
  • 1
    What have you tried since you asked the [same question](http://stackoverflow.com/questions/9156737/mobile-number-validation-in-lwuit) previously? – radimpe Feb 28 '12 at 10:25
  • @radimpe , previously i tried this only – Juhi Feb 28 '12 at 11:39

3 Answers3

3

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;
        }
    };
Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46
-2

You must do it by hand. Get the first char and check it against all other until you find a different char. Or You can create a regexp out of the first char and match your value against it.

edit : The question has completely changed. This answer was meant for another question. So is the next answer.

bokan
  • 3,601
  • 2
  • 23
  • 38