I have a TextInput for a specific format of e-mail address, and have a regex to validate it. I would like to validate it while the user types, with the exact value on the TextInput box, but I'm not getting that.
What I have done is actually add that validation to the OnChangeText method of the TextInput object. The mechanics seems to work, but it is validating against the content 1 letter behind the current content.
Ex.: If I have typed "June" it will validate "Jun" only. If I delete the "e", then it will get "June" and subsequently.
Is that correct, or is there somewhere else I can call my validation to have the expected effects?
<TextInput
placeholder='Type in your email'
style={Styles.Input}
onChangeText={(text) => {this.setLogin(text)}}
value={ this.state.login }
autoCompleteType={"email"}
autoFocus={true}
/>
...
...
...
setLogin = (input) => {
this.setState({login: input});
console.log(this.state.login_regex.test(this.state.login));
if (!this.state.login_regex.test(this.state.login)) {
this.setState({login_msg: "Use an internal mail address"});
} else {
this.setState({login_msg: ""});
};
};