This is a more modified version of edittext. in conventional EditText in android we get the default functionalities. but one of the most important functionality is missing in the default EditText. as we know we must have to validate the data before taking it as an input in edittext. so this functionality is provided in this mod.
- Number of Characters limit Validation
- First BlankSpace Validation
- Intermediate BlankSpace Validation
- SQL Injaction Character Validation
- Take Letters Only
- Take Numbers Only
- Receive Validation Failed and Success Broadcast
- Set Custom Error Message
- Phone Number Validation
- Email Validation
- Name Validation
appprojects {
repositories {
maven {
url "https://jitpack.io"
}
}
}
dependencies {
compile 'com.github.sagarnayak:ModifiedEditText:1.2'
}
<com.csmpl.androidlib.edittextmod.EditTextMod xmlns:edittextmod="http://schemas.android.com/apk/res-auto"
android:id="@+id/edittextmod_demo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
edittextmod:FailBroadcast="FAILED"
edittextmod:ValidationType="PHONENUMBER" />
Number of Characters limit Validation can be applied when yoou want to limit the number of characters that you want the user to enter. if you want only 10 characters to be entered then just meke a limit of 10.
edittextmod:LimitInput="4"
Setting this value as true will not allow a blank space to be entered at first place.
edittextmod:BlockFirstSpace="true"
Setting this value as true will not allow a blank space to be entered at any position.
edittextmod:BlockIntermediateSpace="true"
Setting this value as true will not allow a sql injection characters ( < , > , = , ~ , # , ^ , | , $ , % , " , & , * , ! , ' ) to be entered at any position.
edittextmod:BlockSqlInjection="true"
Setting this value as true will not allow characters other then letters at any position.
edittextmod:TakeOnlyLetters="true"
Setting this value as true will not allow characters other then numbers at any position.
edittextmod:TakeOnlyNumbers="true"
This parameter will require you to provide a string. this string will be broadcasted whenever there is a success or a fail in validtion as per what you have used this for. Register for broadcast with this name you have provided in the activity to receive a failed or success broadcast.
edittextmod:FailBroadcast="FAILED_BORADCAST"
edittextmod:SuccessBroadcast="SUCCESS_BROADCAST"
This parameter will require you to provide a error message as string. this is optional. if you dont want to provide a custom error message then it will show a default error message while validating.
edittextmod:error_message="Please enter correct data"
If you are aiming for a specific phone number validation then use this validation. this will take only numbers and the default number of characters are 10. if you want you can change it by applying a "Number of Characters limit Validation". by default the number keyboard will be opened. this includes a first blankspace and inermediate blannk space validation also, including the sql injection.
edittextmod:ValidationType="PHONENUMBER"
If you are aiming for a specific email address validation then use this validation. this will validate a proper email and will return a error message if you a proper email address is not entered.this includes a first blankspace and inermediate blannk space validation also, including the sql injection.
edittextmod:ValidationType="EMAILADDRESS"
If you are aiming for a specific name validation then use this validation. this will take a name and if any other character is entered then this will show an error message.this includes a first blankspace validation also, including the sql injection.
edittextmod:ValidationType="NAME"
At any point if the focus is changed and the validation is not successfull the edittext will not loose the focus. it will regain focus and request the user to enter a proper data by showing a proper error message.