修复注册登录输入框限制等bug

This commit is contained in:
zhouyanli
2026-08-03 17:39:27 +08:00
parent 015ed25400
commit 5c8671a91e
6 changed files with 39 additions and 33 deletions

View File

@@ -128,13 +128,13 @@
agreeAgreement.value;
});
// 实时校验密码格式(输入空格或特殊符号立即提示
// 实时校验密码格式(禁止颜文字/emoji/特殊符号,只允许中文、字母、数字
watch(password, (val) => {
if (!val) { passwordError.value = ''; return }
if (val.length < 6 || val.length > 16) {
passwordError.value = '密码需 6-16 位'
} else if (/[^a-zA-Z0-9]/.test(val)) {
passwordError.value = '密码格式错误'
} else if (/[^一-龥a-zA-Z0-9]/.test(val)) {
passwordError.value = '密码不能包含特殊符号或表情'
} else {
passwordError.value = ''
}
@@ -149,7 +149,7 @@
agreeAgreement.value = !agreeAgreement.value;
};
// 账号失焦校验
// 账号失焦校验(禁止颜文字/emoji/特殊符号,只允许中文、字母、数字)
const validateAccount = () => {
const val = account.value
if (!val) { accountError.value = ''; return }
@@ -157,6 +157,8 @@
accountError.value = '账号不能包含空格'
} else if (val.length < 4 || val.length > 20) {
accountError.value = '账号需 4-20 位'
} else if (/[^一-龥a-zA-Z0-9]/.test(val)) {
accountError.value = '账号不能包含特殊符号或表情'
} else {
accountError.value = ''
}
@@ -167,14 +169,14 @@
accountError.value = ''
};
// 密码失焦校验
// 密码失焦校验(禁止颜文字/emoji/特殊符号,只允许中文、字母、数字)
const validatePassword = () => {
const val = password.value
if (!val) { passwordError.value = ''; return }
if (val.length < 6 || val.length > 16) {
passwordError.value = '密码需 6-16 位'
} else if (/[^a-zA-Z0-9]/.test(val)) {
passwordError.value = '密码格式错误'
} else if (/[^一-龥a-zA-Z0-9]/.test(val)) {
passwordError.value = '密码不能包含特殊符号或表情'
} else {
passwordError.value = ''
}
@@ -286,7 +288,11 @@
return;
}
if (/\s/.test(account.value)) {
uni.showToast({ title: '账号格式不对,不允许注册', icon: 'none' });
uni.showToast({ title: '账号不能包含空格', icon: 'none' });
return;
}
if (/[^一-龥a-zA-Z0-9]/.test(account.value)) {
uni.showToast({ title: '账号不能包含特殊符号或表情', icon: 'none' });
return;
}
if (!password.value) {
@@ -301,8 +307,8 @@
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
return;
}
if (/[^a-zA-Z0-9]/.test(password.value)) {
uni.showToast({ title: '密码格式错误', icon: 'none' });
if (/[^一-龥a-zA-Z0-9]/.test(password.value)) {
uni.showToast({ title: '密码不能包含特殊符号或表情', icon: 'none' });
return;
}
if (!agreeAgreement.value) {