Last active
March 16, 2022 18:37
-
-
Save seemike/6388429 to your computer and use it in GitHub Desktop.
Android: restrict EditText field input to alphanumeric characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<EditText | |
android:inputType="textNoSuggestions" | |
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" | |
/> |
Try this
String correct= text.getText().to String ()
String formatingValue=correct.replaceAll("[a-zA-Z0-9]","");
This how it works it will get all special characters and replace them with empty string.
This is working for me. Thanks 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I want to allow only capital letters,number and space.
I did everything but emoji and other special characters not getting disable.
any solution?