修复bug
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
<image src="https://wuyeadmin.bugtc.com/images/login/password.png" mode=""
|
||||
style="height: 100%;width: 100%;"></image>
|
||||
</view>
|
||||
<uni-easyinput class="input-content" type="password" v-model="password" @input="password = password.replace(/\s/g, '')" @blur="validatePassword" @focus="clearPasswordError" placeholder="请输入密码(6-16位)"
|
||||
<uni-easyinput class="input-content" type="password" v-model="password" @blur="validatePassword" @focus="clearPasswordError" placeholder="请输入密码(6-16位)"
|
||||
:inputBorder="false" maxlength="16" :placeholderStyle="placeholderStyle" />
|
||||
</view>
|
||||
<text class="input-error" v-if="passwordError">{{ passwordError }}</text>
|
||||
@@ -86,6 +86,7 @@
|
||||
import {
|
||||
ref,
|
||||
computed,
|
||||
watch,
|
||||
onUnmounted
|
||||
} from 'vue';
|
||||
import {
|
||||
@@ -127,6 +128,18 @@
|
||||
agreeAgreement.value;
|
||||
});
|
||||
|
||||
// 实时校验密码格式(输入空格或特殊符号立即提示)
|
||||
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 {
|
||||
passwordError.value = ''
|
||||
}
|
||||
})
|
||||
|
||||
// ========== 方法 ==========
|
||||
const goBack = () => {
|
||||
uni.navigateBack();
|
||||
@@ -160,8 +173,8 @@
|
||||
if (!val) { passwordError.value = ''; return }
|
||||
if (val.length < 6 || val.length > 16) {
|
||||
passwordError.value = '密码需 6-16 位'
|
||||
} else if (/\s/.test(val)) {
|
||||
passwordError.value = '密码不能包含空格'
|
||||
} else if (/[^a-zA-Z0-9]/.test(val)) {
|
||||
passwordError.value = '密码格式错误'
|
||||
} else {
|
||||
passwordError.value = ''
|
||||
}
|
||||
@@ -288,8 +301,8 @@
|
||||
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (/\s/.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) {
|
||||
|
||||
Reference in New Issue
Block a user