TSValidatedTextField
TSValidatedTextField copied to clipboard
Validation issue with Gboard (and with other 3rd party keyboards)
Summary
If users chose to use a custom 3rd party keyboard for interacting with the input field, the validatedFieldBlock will only get called before the last edit.
Example
In case of abcd input the block will call only for a, ab, and abc.
In case of deleting the whole content, the block will call for abcd, abc, ab, a
(always missing the last change)
Workaround
Listening to the UIControlEventEditingChanged notification and calling the validate method once again (after the edit) solves the issue manually, as it triggers firing the validatedFieldBlock.
- ... {
[textField addTarget:self action:@selector(textChanged) forControlEvents:UIControlEventEditingChanged];
}
- (void)textChanged {
[textField validate];
}