0

How can I restrict the user to input in textfield/textbox to alphanumeric only in J2ME ? I don't want the user to input !@##$%$#*& <-- these special characters.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
selva
  • 446
  • 1
  • 7
  • 21

1 Answers1

1

override method TextField in way below and put logic their

TextField t = new TextField(){
            protected boolean validChar(String c) {         
                  if ((c.charAt(0) > '0' && c.charAt(0) < '9') || (c.charAt(0) > 'a' && c.charAt(0) < 'z') || (c.charAt(0) > 'A' && c.charAt(0) < 'Z' )) {
                    return true;
                }else{
                    return false;
                }
            }
        };
Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46