From aec4be10c526d5d5d4c0fc7917511a85e6380841 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期一, 07 八月 2023 10:17:05 +0800 Subject: [PATCH] 菜单接口 --- src/utils/toolsValidate.ts | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-) diff --git a/src/utils/toolsValidate.ts b/src/utils/toolsValidate.ts index 434466e..da8421e 100644 --- a/src/utils/toolsValidate.ts +++ b/src/utils/toolsValidate.ts @@ -210,7 +210,7 @@ */ export function verifyPhone(val: string) { // false: 手机号码不正确 - if (!/^((12[0-9])|(13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0|1,5-9]))\d{8}$/.test(val)) return false; + if (!/^((12[0-9])|(13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17([7-9]))|(18[0|1,5-9]))\d{8}$/.test(val)) return false; // true: 手机号码正确 else return true; } @@ -366,3 +366,55 @@ // true:车牌号正确 else return true; } + +export function checkChineseName (name:string) { + let reg = /^[\u4e00-\u9fa5]{2,15}$/; + // 保留点后,用来校验的姓名,也是最终校验通过后返回的姓名 + let payerName = name.replaceAll(" ", "") + .replaceAll(" ", "") + .replaceAll("•", "·") + .replaceAll(".", "·"); + // 去除所有点后,用来校验的姓名 + let checkName = name.replaceAll(" ", "") + .replaceAll(" ", "") + .replaceAll("•", "") + .replaceAll(".", "") + .replaceAll("·", ""); + if(checkName.length === 1){ + // this.$message({ + // type:'warning', + // message:'姓名至少包含两位汉字' + // }) + return false; + } + if (reg.test(checkName)) { + if(payerName.substring(0,1) === '·'){ + // this.$message({ + // type:'warning', + // message:'姓名第一位不能为“·”' + // }) + return false; + } + if(payerName.substring(payerName.length - 1) === '·'){ + // this.$message({ + // type:'warning', + // message:'姓名最后不能为“·”' + // }) + return false; + } + if(payerName.indexOf("··") !== -1){ + // this.$message({ + // type:'warning', + // message:'姓名不能有连续的“·”' + // }) + return false; + } + return payerName; + } else { + // this.$message({ + // type:'warning', + // message:'姓名中只能包含汉字和“·”' + // }) + return false; + } +} -- Gitblit v1.9.2