react-native - 如何检查电子邮件格式是否有效?并且两个密码匹配?反应原生
问题描述
我在 React Native 中做了一个简单的注册表单。我想检查电子邮件格式是否有效,我希望用户重新输入密码并检查两个密码是否相互匹配。我是新手,所以请让我知道如何将您的代码与我的代码结合起来。
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 }
解决方案
这可能会有所帮助:https://stackoverflow.com/questions/61933102/sending-verification-email-with-firebase-and-react-native\ 我认为除了解析之外没有办法检查某些内容是否有效字符串 a 检查它是否在正确的位置包含 @ 和 .com/org/etc..,除了发送和电子邮件并等待无响应。
推荐阅读
- javascript - 用 JavaScript 中的 CSS 属性替换 HTML 元素中的 CSS 类
- javascript - 尝试使用 d3.select() 选择 React DOM ref 并遇到错误
- pytorch - 任意选择的值作为标准化的标准/平均值。为什么?
- c# - 在 C# 中将类实例转换为原始字节数组
- android - 如何从不同的谷歌帐户的firebase控制台/android工作室查看、修改现有firebase android项目的数据库?
- python - 解包值过多时出现错误(预期2)
- python - 扩展模板中的 Django 表单
- r - 使用 rvest 进行网页抓取:无法区分的 CSS 选择器阻止我抓取某些块
- html - 创建一个内部显示“是”“否”的开关切换
- laravel - 多态OneToMany图像-产品关系,如何知道哪些图像是哪些?