Browse Source

限制特殊符号输入

main
Linzm 2 months ago
parent
commit
1c89f495a7
  1. 13
      src/views/badge/preview.vue

13
src/views/badge/preview.vue

@ -952,11 +952,11 @@ const frontTextShow = (event: any, isFront: boolean | null = null) => { @@ -952,11 +952,11 @@ const frontTextShow = (event: any, isFront: boolean | null = null) => {
const shapeText = ref('')
const changeShapeText = (e: any) => {
console.log('changeShapeText', e.target.value)
// if (!validateInput(e.target.value)) {
// showToast('')
// shapeText.value = e.target.value.replace(/[^a-zA-Z0-9\u4e00-\u9fa5\s]/g, '');
// return;
// }
if (!validateInput(e.target.value)) {
showToast('输入的文字不能包含特殊符号!')
shapeText.value = e.target.value.replace(/[^a-zA-Z0-9\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7a3\u00c0-\u017f\s~!@#¥%……&*()——+_)(*&^%$#@!~?><:"}{|、】【';、。,'.]/g, '');
return;
}
handleInput(e.target.value)
}
@ -995,8 +995,7 @@ const changeBackText = (e: any) => { @@ -995,8 +995,7 @@ const changeBackText = (e: any) => {
}
const validateInput = (input: string) => {
//
const regex = /^[a-zA-Z0-9\u4e00-\u9fa5\s]+$/;
const regex = /^[a-zA-Z0-9\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7a3\u00c0-\u017f\s~!@#¥%……&*()——+_)(*&^%$#@!~?><:"}{|、】【';、。,'.]+$/;
return regex.test(input);
}

Loading…
Cancel
Save