I use the android-saripaar library.
I can check all the EditText
fields on the correctness of the entered data using validate()
. If I fill the EditText
on with a mistake in correct data, the error doesn't disappear as long as I again call a validate()
.
How can I check the validity after entering text only in a certain EditText
and to remove a mistake from it?
Thanks.
You can use Saripaar's
Mode.IMMEDIATE
in combination withTextWatcher
instances to accomplish what you are looking for.@Order
annotation one every view fields that have Saripaar annotations. This is required to use immediate validation mode. If you want to validate rules in a specific order, each saripaar annotation has asequence
attribute. Thesequence
attribute is optional, but very helpful if you want the rules to be validated in a specific sequence.Set the mode to immediate
mValidator.setMode(Mode.IMMEDIATE)
Add
TextWatcher
s / appropriate listeners to your widgets.ViewValidatedAction
implementation that will automatically clear errors onEditText
fields when it is valid. If your form uses alternate error display mechanism / widgets, you can clear them by specifying your ownViewValidatedAction
instance.Disclosure: I'm the author of Saripaar