手机号邮箱正则表达

 
    async postphoneBinding(User, phone) {
      let temp = await http.phoneBinding(User, phone);
      let tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(
        this.phone
      );
      if (temp == null && tel) {
        // console.log('验证码已发送')
        alert("验证码已发送");
      } else if (this.phone == "") {
        alert("请输入手机号");
        return false;
      } else if (!tel) {
        alert("手机号不正确");
      }
      console.log(temp);
    },

 {
    field: 'phone',
    label: t('theform.public.Phone'),
    component: 'Input',
    rules: [
      {
        trigger: 'phone',
      },
    ],
    dynamicRules: ({}) => {
      return [
        {
          required: true,
          validator: (_, value) => {
            const tel =
              /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(
                value,
              );
            if (!value) {
              return Promise.reject(t('theform.public.nullPhone'));
            }
            if (!tel) {
              return Promise.reject(t('theform.public.errPhone'));
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
 三邮箱
 {
    field: 'email',
    label: t('theform.Management.Emailaddress'),
    component: 'Input',
    // required: true,
    rules: [
      {
        trigger: 'Email',
      },
    ],
    dynamicRules: ({}) => {
      return [
        {
          required: true,
          validator: (_, value) => {
            const regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(value);
            if (!value) {
              return Promise.reject(t('theform.Management.nullerrEmail'));
            }
            if (!regEmail) {
              return Promise.reject(t('theform.Management.errEmail'));
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
 

 

posted @ 2021-05-12 10:02  zjxgdq  阅读(80)  评论(0编辑  收藏  举报