I am using expo with React Native and I am trying to set error message when the email format is not valid
this is my function:
const emailValidator = (email: any) => { let reg = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/; if (reg.test(email) === false) { setErrorMassage2( "Please enter a valid email address" ); return false; } else { setErrorMassage2( "" ); }};
this is my text input:
<TextInput style={styles.textInput} autoCapitalize="none" onChangeText={(e) => setEmail(e.toString())} onBlur={(email) => emailValidator(email)} /><Text> {errorMassage2}</Text>
but it does not work, anyone have idea?