I want to show error if user only enters spaces in EditText but i don't know how?
Here is my simple work
if (tName.getText().toString().matches(" ")) {
Toast.makeText(MainActivity.this, "Must Add Your Name Here", Toast.LENGTH_SHORT).show();
}
Try with this code
if(!editText.getText().toString().trim().isEmpty()){
editText.setError("Empty spaces are not allowed");
editText.setFocusable(true);
Toast.makeText(MainActivity.this, "Must Add Your Name Here", Toast.LENGTH_SHORT).show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With