ElementUI验证手机号

技术 · 2023-10-17

ElementUI验证手机号:

rules: {
  phone: [
          {
            required: true,
            validator: (rule, value, callback) => {
              if (!value) callback(new Error('请输入联系电话!'));
              if (!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(value))
                callback(new Error('请输入正确的联系电话!'));
              callback();
            },
            trigger: ['blur', 'change']
          }
        ]

}
ElementUI
  1. 云晓晨 2023-11-30

    这是正则表达式嘛?

Theme Jasmine by Kent Liao