wangRong-smile

^([\u4e00-\u9fa5]{2,20}|[a-zA-Z.\s]{2,20})$ 姓名长度必须为2-20个字符

/**
* 1.可以是中文
2.可以是英文,允许输入点(英文名字中的那种点), 允许输入空格
3.中文和英文不能同时出现
4.长度在20个字符以内
* @param name
* @return
*/

     let nameReg =  /^([\u4e00-\u9fa5]{2,20}|[a-zA-Z.\s]{2,20})$/;
        if(this.form.value2){
          if(nameReg.test(this.form.value2)){
            console.log(\'111\')
          }else{
            this.showPositionValue = true;
            this.toastText = "姓名格式不正确!";
          }
        }else{
          this.showPositionValue = true;
          this.toastText = "请输入姓名!";
        }

  

分类:

技术点:

相关文章: