Android EditText Validation Example

Android EditText Validation Example

Android EditText Validation Example

Android EditText Validation Example explains how you can add validation to your EditText Control of android. The important feature of this android tutorial is that it’s only 1 line to validate EditText text. Here I have prepared the tutorial for validating Blank Text Box Validation, Email Address Validation, Website Validation.

new to android development? Check android step by step guide.

android tips and trick to save your time

Need help in logic building, check article

Question-related with EditText Validation.

What is EditText? How to create it? Explain with the example how to constraint the user input with EditText.

Explain the setFilters() method that can be used with EditText control.


Here is the sample code to validate android edittext and display message at the end of edittext

//Validation for Blank Field
Toast.makeText(getApplicationContext(), “Name cannot be Blank”, Toast.LENGTH_LONG).show();
et1.setError(“Name cannot be Blank”);
else if(!android.util.Patterns.EMAIL_ADDRESS.matcher(et2.getText().toString()).matches())
//Validation for Invalid Email Address
Toast.makeText(getApplicationContext(), “Invalid Email”, Toast.LENGTH_LONG).show();
et2.setError(“Invalid Email”);
else if(!android.util.Patterns.DOMAIN_NAME.matcher(et3.getText().toString()).matches())
//Validation for Website Address
Toast.makeText(getApplicationContext(), “Invalid Website”, Toast.LENGTH_LONG).show();
et3.setError(“Invalid Website”);
Toast.makeText(getApplicationContext(), “Validated Succesfully”, Toast.LENGTH_LONG).show();


Continue reading article : Output


Are you android developer? Want to save your time? Check out Android Tips and Tricks

Few More article on android tutorial:

android textview underline tutorial

android frame by frame animation


android video tutorial

java video tutorial

c programming tutorial


Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative