React native 如何检查电子邮件格式是否有效?两个密码匹配吗?自然反应
我用React Native做了一个简单的登记表。我想检查电子邮件格式是否有效,我想让用户重新输入密码,并检查两个密码是否匹配。我是新手,所以请让我知道如何将你的代码与我的代码结合起来React native 如何检查电子邮件格式是否有效?两个密码匹配吗?自然反应,react-native,React Native,我用React Native做了一个简单的登记表。我想检查电子邮件格式是否有效,我想让用户重新输入密码,并检查两个密码是否匹配。我是新手,所以请让我知道如何将你的代码与我的代码结合起来 export class Register extends Component { constructor(props) { super(props); this.state = { email: '',
export class Register extends Component {
constructor(props) {
super(props);
this.state = {
email: '',
password: '',
name: '',
lastname: ''
}
this.onSignUp = this.onSignUp.bind(this)
}
onSignUp(){
if(
this.state.email != '' &&
this.state.password != '' &&
this.state.name != ''
){
const { email, password, name } = this.state;
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((result) => {
firebase.firestore().collection("Users")
.doc(firebase.auth().currentUser.uid)
.set({
name,
email
})
console.log(result)
})
.catch((error) => {
console.log(error)
})
}
else{
alert("Please fill the empty spaces!");
}
}
render() { form body }
这可能有助于:
我认为除了解析字符串a检查是否包含@和.com/org/等之外,没有办法检查某个东西是否是有效的电子邮件。。在正确的地方,除了发送电子邮件和等待无响应