0

I want to restrict special character when user type on edittext, how I can achieve it, I tried:

public boolean validateBuisnessName(EditText et, String name, TextInputLayout textInputLayout) {
  String alphaRegex = ".*[A-Z0-9].*";

  // Check if pattern matches
  if (name.matches(alphaRegex)) {
     textInputLayout.setErrorEnabled(false);
  } else {
     textInputLayout.setError("Invalid Buisness Name");
     return false;
  }
  return true;
}
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Amit Ranjan
  • 83
  • 1
  • 9
  • 1
    Possible duplicate of [How to exclude special characters from android keypad for EditText](http://stackoverflow.com/questions/7335455/how-to-exclude-special-characters-from-android-keypad-for-edittext) – cpt. Sparrow Feb 07 '17 at 11:46
  • how to check the validation? – Amit Ranjan Feb 07 '17 at 11:48

0 Answers0