diff --git a/packages/react-vant/src/components/form/demo/rules.tsx b/packages/react-vant/src/components/form/demo/rules.tsx index cc9e0c43a..11f9efabf 100644 --- a/packages/react-vant/src/components/form/demo/rules.tsx +++ b/packages/react-vant/src/components/form/demo/rules.tsx @@ -20,7 +20,7 @@ export default () => { @@ -30,7 +30,7 @@ export default () => { rules={[ { validator: (_, value) => { - if (/1\d{10}/.test(value)) { + if (/^1\d{10}$/.test(value)) { return Promise.resolve(true) } return Promise.reject(new Error('请输入正确的手机号码')) @@ -50,7 +50,7 @@ export default () => { Toast.loading('验证中...') setTimeout(() => { - if (/\d{6}/.test(value)) { + if (/^\d{6}$/.test(value)) { resolve(true) } else { reject(new Error('请输入正确内容'))