限制特殊符号输入

This commit is contained in:
Linzm committed 2025-08-18 11:16:59 +08:00
1 parent b63bbbf645
commit 2e6ba98431
1 file changed
+10
+10
View File
@@ -685,7 +685,17 @@ const textShow = (item: any) => {
const shapeText = ref('') const shapeText = ref('')
const changeShapeText = (e: any) => { const changeShapeText = (e: any) => {
console.log('changeShapeText', e.target.value) console.log('changeShapeText', e.target.value)
if (!validateInput(e.target.value)) {
showToast('输入的文字不能包含特殊符号!')
} else {
handleInput(e.target.value) handleInput(e.target.value)
}
}
const validateInput = (input: string) => {
// 正则说明:只允许字母(大小写)、数字、中文和空格
const regex = /^[a-zA-Z0-9\u4e00-\u9fa5\s]+$/;
return regex.test(input);
} }
const handleInput = (value: string) => { const handleInput = (value: string) => {