How can I check the value entered in EditText is aplhanumeric or not?
3 answers
http://osdir.com/ml/Android-Developers/2009-11/msg02501.html seems to be a more decent solution, it doesn't allow characters that are not accepted.
The code from the link:
InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (!Character.isLetterOrDigit(source.charAt(i))) {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[]{filter});
+3
a source to share