How to restrict special characters from an Android EditText field?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have you tried adding the
android:digits="abcde.....0123456789"attribute?Although the
android:digitsspecify that it is a numeric field, it does work for me to set it to accept letters as well, and special characters as well (tested on SDK-7).If this doesn’t work then you’ll have to implement
KeyListenersee: http://developer.android.com/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)