I am trying to validate a users email, by checking it against an expression. But the result i am getting is invalid for all the entries.
UPDATED CODE
validate = (text) => {
console.log(text);
let reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/ ;
if(reg.test(text) === false)
{
alert("Email is Not Correct");
this.setState({email:text})
return false;
}
else {
this.setState({email:text})
alert("Email is Correct");
}
}
You can put this function validate in onChangeText propert of TextInput