If you want to validate TextInput values in react native? You can use a regex to check if the mail entered is valid.
Regex function
1 2 3 4 5 6 7 | validateEmail = (email) => { ((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.) +[a-zA-Z]{2,}))$/; return re.test(email); }; |
Submit text input function
1 2 3 4 5 6 | onSubmit = () => { if (!this.validateEmail(this.state.text_input_email)) { // not a valid email } else { // valid email } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.