JS判断输入框值是否为空


this.program = this.program.replace(/(^\s*)|(\s*$)/g, '');  //去除空格;
console.log('此刻的方案:',this.program)
if (this.program == '' || this.program == undefined || this.program == null) {
    this.$message.error('不能输入为空、空格');
}

ok已经替代了我之前的简单判空的方法:
// if(!this.program) {
    //this.$message.error('请填写方案名称');
// };

  

   let star = this.state.contentxiao.replace(/(^\s*)|(\s*$)/g, "");
    if (star === "" || star === undefined || star === null) {
      // 清空输入框的值
      this.setState({
        contentxiao: "",
      });
      return;
    }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM