mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
opt: add email and mobile validation for register
This commit is contained in:
parent
06fb7b41b4
commit
180bd2a1db
@ -80,6 +80,9 @@ const register = function () {
|
||||
if (formData.value.username.length < 4) {
|
||||
return ElMessage.error('用户名的长度为4-30个字符');
|
||||
}
|
||||
if (!validateEmail(formData.value.username) && !validateMobile(formData.value.username)) {
|
||||
return ElMessage.error('用户名不合法,请输入手机号码或者邮箱地址');
|
||||
}
|
||||
if (formData.value.password.length < 8) {
|
||||
return ElMessage.error('密码的长度为8-16个字符');
|
||||
}
|
||||
@ -94,6 +97,15 @@ const register = function () {
|
||||
})
|
||||
}
|
||||
|
||||
const validateEmail = function (email) {
|
||||
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return regex.test(email);
|
||||
}
|
||||
const validateMobile = function (mobile) {
|
||||
const regex = /^1[345789]\d{9}$/;
|
||||
return regex.test(mobile);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
|
Loading…
Reference in New Issue
Block a user