android-edittext-validator alternatives and similar packages
Based on the "TextView/EditText Widget" category.
Alternatively, view android-edittext-validator alternatives based on common mentions on social networks and blogs.
-
ExpandableTextView
Android's TextView that can expand/collapse like the Google Play's app description -
android-autofittextview
A TextView that automatically resizes text to fit perfectly within its bounds. -
AutoLinkTextView
AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks. -
Android-RobotoTextView
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts. -
WaitingDots
Small library that provides... bouncing dots. This feature is used in number of messaging apps (such as Hangouts or Messenger), and lately in Android TV (for example when connecting to Wifi). -
SecretTextView
A TextView that simulates the effect from the app Secret where the characters fade in/out at different speeds. -
AwesomeText
A tool that facilitates working with Spans on TextViews or any extension of them (EditTexts, Buttons...). -
Masked-Edittext
Android library contain custom realisation of EditText component for masking and formatting input text -
AnimatedEditText
Androids EditText that animates the typed text. EditText is extended to create AnimatedEditText and a PinEntryEditText. -
chips-edittext-library
Chips EditText, Token EditText, Bubble EditText, Spannable EditText and etc.. There are many names of this control. Here I develop easy to understand , modify and integrate Chips Edit Text widget for Android -
EmailAutoCompleteTextView
An AutoCompleteTextView with builtin Adapter with the emails in the device. -
CurrencyEditText
A module designed to encapsulate the use of an Android EditText field for gathering currency information from a user. Supports all ISO-3166 compliant locales/currencies. -
AutosizeEditText
AutosizeEditText for Android is an extension of native EditText that offer a smooth auto scale text size. -
Android-SingleInputForm
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform -
android-formidable-validation
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies. -
anytextview
An extension of Android's TextView, EditText and Button that let's you use the font of your choice -
MaskFormatter
Add text masking functionality to Android EditText. It will prevent user from inserting not allowed signs, and format input as well. -
KerningViews
Provides a set of views which allows to adjust the spacing between the characters of that view, AKA, Kerning effect. -
SimpleLinkableText
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of android-edittext-validator or a related project?
README
Android Form EditText
Android form edit text is an extension of EditText that brings data validation facilities to the edittext.
Example App
I built an example app that showcase some of the possibilities of the library.
You'll be able to find the app in the Play Store Here some screenshot of the Example app ( and the library )
-
The app source code is located under this repo!
How to include it
This library can be found in maven central repo. If you're using Android studio you can include it by writing the following in the corresponding dependencies block
Gradle:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
// ...
compile 'com.andreabaccega:android-edittext-validator:1.3.5'
// ...
}
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.andreabaccega</groupId>
<artifactId>android-edittext-validator</artifactId>
<version>${...}</version>
<type>aar</type>
<scope>provided</scope>
</dependency>
Since 1.3.+ the library comes with a new optional dependency: com.android.support.design. This will enable the new TextInputLayout features to be used with the validation engine. Version 1.3.+ depends on com.android.support.design:2.2.0 but if you're not using the support design library you can safely exclude it while including this with gradle by doing so:
dependencies {
// ..
implementation 'com.andreabaccega:android-form-edittext:1.3.5'
// ..
}
How to use
In your xml import an extra namespace on the root of your layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
....
<!-- Your actual layout -->
....
</LinearLayout>
Note: It's not mandatory to use it on the root element. Also remember to change the xmlns value with your package name
Whenever you need to use the FormEditText just do the following in your xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Some stuff -->
<com.andreabaccega.widget.FormEditText
whatever:testType="alpha"
android:id="@+id/et_firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!-- Some other stuff -->
</LinearLayout>
As you noticed there is a whatever:test attribute setted to alpha. This let the FormEditText know that the data inside it should be only Alpha characters.
There are several values you can set to the test attribute:
- regexp: for custom regexp
- numeric: for an only numeric field
- alpha: for an alpha only field
- alphaNumeric: guess what?
- email: checks that the field is a valid email
- creditCard: checks that the field contains a valid credit card using Luhn Algorithm
- phone: checks that the field contains a valid phone number
- domainName: checks that field contains a valid domain name
- ipAddress: checks that the field contains a valid ip address
- webUrl: checks that the field contains a valid url
- personName: checks if the entered text is a person first or last name.
- personFullName: checks if the entered value is a complete full name.
- date: checks that the field is a valid date/datetime format ( if customFormat is set, checks with customFormat )
- numericRange: checks that the field is a valid value between integers. (minNumber and maxNumber must be set)
- floatNumericRange: checks that the field is a valid value between integers (but decimal values are allowed). (minNumber and maxNumber must be set)
- nocheck: It does not check anything except the emptyness of the field.
For most of the test type values this library comes with a couple of default strings. This means that error strings ( english only ) are already available for the following test types: numeric, alpha, alphanumeric
You can customize them using the attributes
- testErrorString used when the field does not pass the test
- emptyErrorString used when the field is empty
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Some stuff -->
<com.andreabaccega.widget.FormEditText
whatever:testType="alpha"
whatever:emptyErrorString="@string/your_name_cannot_be_empty"
whatever:testErrorString="@string/your_name_is_ugly"
android:id="@+id/et_firstname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!-- Some other stuff -->
</LinearLayout>
Furthermore you can ask the FormEditText to allow the content to be optional. Just use the emptyAllowed attribute and set it to true. Note: If you don't specify the emptyAllowed attribute the default value is false.
If you want to use regexp as test attribute value you'll need to also use the customRegexp attribute. Take a look in the following example:
Example: (Email check)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- Some stuff -->
<com.andreabaccega.widget.FormEditText
whatever:testType="regexp"
whatever:customRegexp="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$"
whatever:testErrorString="@string/error_emailnotvalid"
android:id="@+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_email"
android:inputType="textEmailAddress"
/>
<!-- Some other stuff -->
</LinearLayout>
Note: The library supports the email check natively using the email value as the test attribute.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Some stuff -->
<com.andreabaccega.widget.FormEditText
whatever:testType="email"
android:id="@+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_email"
android:inputType="textEmailAddress"
/>
<!-- Some other stuff -->
</LinearLayout>
In your Java code you'll need to call a method when you want to know if the field validates.
public void onClickNext(View v) {
FormEditText[] allFields = { etFirstname, etLastname, etAddress, etZipcode, etCity };
boolean allValid = true;
for (FormEditText field: allFields) {
allValid = field.testValidity() && allValid;
}
if (allValid) {
// YAY
} else {
// EditText are going to appear with an exclamation mark and an explicative message.
}
}
Calling testValidity() will cause the EditText to cycle through all the validators and call the isValid method. it will stop when one of them returns false or there are no validators left.
Furthermore testValidity() will also place an exclamation mark on the right of the EditText and will call the setError method.
Add your custom validators
You can add your custom validators runtime through the addValidator method. For example, let's suppouse we want to add a validator that checks that the text input is equal to the string "ciao":
public class CiaoValidator extends Validator {
public CiaoValidator() {
super("You should enter 'ciao' here");
}
public boolean isValid(EditText et) {
return TextUtils.equals(et.getText(), "ciao");
}
}
As you can see in the constructor you'll be required to set an Error Message that will be handled ( in this simple scenario ) by the super class. That piece of code will set the error message to: You should enter 'ciao' here.
This means that if the user will not enter "ciao" in the edit text it will get that error message in the popup.
Binary operators
You can use the following binary operators in order to perform checks on the field value:
- AND: will return true if every enqueued validator returns true
- OR: will return true if just one enqueued validator returns true
- NOT: will return the inverse of the passed Validator
With these binary operator validators you'll be able to perform as many different checks as you want. For example, lets say you want a field to be valid either if the user enters his email address or his credit card. Use 'nocheck' in the xml and programmatically do something like this:
protected void onCreate(Bundle savedInstanceState) {
// Blabla
FormEditText fdt = (FormEditText) findViewById(R.id.et);
fdt.addValidator(
new OrValidator(
"This is neither a creditcard or an email",
new CreditCardValidator(null), // we specify null as the message string cause the Or validator will use his own message
new EmailValidator(null) // same here for null
)
);
}
Author
- Andrea Baccega [email protected] - Author/Ideator of the library
Contributors
- ffrog8 - Added the ability to use the library inside the preferences
- indication - Added japanese translations
- renclav - Fixed weird bug affecting some 4.2+ devices that prevented the error icon to be shown