开发者

Restrict the input in textfield/textbox to alphanumeric only in J2me

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.


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;
                }
            }
        };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜