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.IMMEDIATEin combination withTextWatcherinstances to accomplish what you are looking for.@Orderannotation 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 asequenceattribute. Thesequenceattribute is optional, but very helpful if you want the rules to be validated in a specific sequence.@Order(1) @NotEmpty(sequence = 1) @Email(seqence = 2) private EditText mEmailEditText; @Order(2) @Password private EditText mPasswordEditText;Set the mode to immediate
mValidator.setMode(Mode.IMMEDIATE)Add
TextWatchers / appropriate listeners to your widgets.TextWatcher validationTextWatcher = new TextWatcher() { @Override void afterTextChanged(Editable s) { mValidator.validate(); } // Other methods to override ... } mEmailEditText.addTextChangedListener(validationTextWatcher); mPasswordEditText.addTextChangedListener(validationTextWatcher);ViewValidatedActionimplementation that will automatically clear errors onEditTextfields when it is valid. If your form uses alternate error display mechanism / widgets, you can clear them by specifying your ownViewValidatedActioninstance.mValidator.setViewValidatedAction(new ViewValidatedAction() { @Override void onAllRulesPassed(View view) { // ... clear errors based on the view type } });Disclosure: I'm the author of Saripaar