el-input的rules验证

 rules: {
        appraisalType: [{ required: true, message: "考核类型必选" }],
        subModelName: [
          { required: true, message: "请输入部门名称", trigger: "blur" },
          { max: 30, message: "长度在30 个字符以内", trigger: "blur" },
          {
            pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+$/,
            message: "不允许输入空格等特殊符号",
          },
  {
            pattern: /^[0-9a-zA-Z\u4e00-\u9fa5]{1,30}$/,
            message: "30个以内请输中英文及数字",
          },

        ],
 quotaWeight: [
            { required: true, message: "请输入权重", trigger: "blur" },
            {
              pattern: /^(?:0|[1-9][0-9]?|100)(\.[0-9]{0,2})?$/,
              message: "只能为0-100之间的整数",
            },
          ],

},

 https://www.jb51.net/article/42693.htm

正则

 https://blog.csdn.net/asdfghjkl521947/article/details/108665312

前端Vue中常用rules校验规则:

1、是否合法IP地址:

pattern:/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,

2.是否手机号码或者固话
pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/,

3. 是否身份证号码
pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,

4.是否邮箱
pattern:/^([a-zA-Z0-9]+[-_\.]?)+@[a-zA-Z0-9]+\.[a-z]+$/,

5.整数填写
pattern:/^-?[1-9]\d*$/,

6.正整数填写
pattern:/^[1-9]\d*$/,

7.小写字母
pattern:/^[a-z]+$/,

8.大写字母
pattern:/^[A-Z]+$/,

9.大小写混合
pattern:/^[A-Za-z]+$/,

10.多个8位数字格式(yyyyMMdd)并以逗号隔开
pattern:/^\d{8}(\,\d{8})*$/,

11.数字加英文,不包含特殊字符
pattern:/^[a-zA-Z0-9]+$/,

12.前两位是数字后一位是英文
pattern:/^\d{2}[a-zA-Z]+$/,

13.密码校验(6-20位英文字母、数字或者符号(除空格),且字母、数字和标点符号至少包含两种)
pattern:/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$)([^\u4e00-\u9fa5\s]){6,20}$/,

14.中文校验
pattern:/^[\u0391-\uFFE5A-Za-z]+$/,

 

posted @ 2020-10-14 16:54  ThisCall  阅读(8596)  评论(0编辑  收藏  举报