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.
Asked
Active
Viewed 2,175 times
1 Answers
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