我想在用户在edittext上输入时限制特殊字符,我怎么能实现它,我试过:
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;
}