zoukankan      html  css  js  c++  java
  • textarea的值转换为JavaScript数组(以换行分隔)验证长度及重复内容 去除空格

    textarea的值转换为JavaScript数组(以换行分隔) 验证长度及重复内容 去除空格
    <el-input
      type="textarea"
      :rows="3"
      placeholder="请输入公司序列号"
      v-model="ruleForm.CompanySerial">
    </el-input>
     
    let lines=this.ruleForm.CompanySerial.split(/ /);
    for (var i=0; i < lines.sort().length; i++) {
      if (/S/.test(lines[i])) {
        if($.trim(lines[i]).length>=50){
        this.$message({
          message: `每条长度不可大于50个字符,错误内容为:${lines[i]}`,
          type: 'error'
        })
        return false 
      }else{
        this.falgLenght=true;
      }
      if($.trim(lines[i])==$.trim(lines[i+1])){
        this.$message({
          message: `序列号有重复内容不可提交,重复内容:${lines[i]}`,
          type: 'error'
        });
      
      this.ruleForm.CompanySerialList=[];
      return false
      }else{
        //定义数组 push到数组中
        this.ruleForm.CompanySerialList.push($.trim(lines[i]));
        this.falg=true;
      }
      }
    }
    if(this.falg && this.falgLenght){
      alert('成立')  
    }
  • 相关阅读:
    路由系统整合
    python操作excel
    Django models ORM基础操作--白话聊Django系列
    Django视图views--白话聊Django系列
    Django分发控制器urls--白话聊Django系列
    HTML页面布局
    一篇搞定SQLAlchemy--关系对象映射
    [LC] 538. Convert BST to Greater Tree
    [LintCode] 535. House Robber III
    [Algo] Rotate String
  • 原文地址:https://www.cnblogs.com/wgy0528/p/11199576.html
Copyright © 2011-2022 走看看