uniapp uview 校验规则记录

js yekong 1349℃
if (!uni.$u.test.rangeLength(this.CustomerName, [2, 50])) {
  uni.showToast({
    title: '请输入企业名称,长度不能超过50字符',
    icon: 'none'
  })
  return
}
// 判断邮箱
if (!uni.$u.test.email(this.Email)) {
  uni.showToast({
    title: '请输入正确的邮箱地址',
    icon: 'none'
  })
  return
}
// 判断是否有邮箱 有的话校验邮箱是不是对
if (this.data.Email) {
  if (!uni.$u.test.email(this.data.Email)) {
    uni.showToast({
      title: '请输入正确邮箱',
      icon: 'none'
    })
    return
  }
}
//判断身份证
if (!uni.$u.test.idCard(that.IDCardNum)) {
  uni.showToast({
    title: '请输入正确身份证号码',
    icon: 'none'
  })
  return
}
//判断是否为空
if (uni.$u.test.isEmpty(this.data.Discount)) {
  this.$refs['showToast'].warn('请输入折扣');
  return
}
喜欢 (0)