Email Validation (React Native). Returning the result as 'invalid' for all the entries

后端 未结 6 710
故里飘歌
故里飘歌 2020-12-30 21:34

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

6条回答
  •  遥遥无期
    2020-12-30 22:07

    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
    

提交回复
热议问题