
// 去除所有空格
export const removeAllSpace=(str)=>{
	return str.replace(/\s+/g, "")
}

// 校验手机号
export const validatePhone = (number) => {
 
  let flag = true
  let myreg = /^1([38]\d|5[0-35-9]|7[3678]|6[0-9]|9[0-9]|4[0-9])\d{8}$/
  if (number.length !== 11 || !myreg.test(number)) {
    flag = false
  }
  return flag
}

// 校验邮箱
export const validateMail = (mail) => {
  if (mail != '') {
    var strRegex = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
    if (!strRegex.test(mail)) {
      return false
    }
  }
  return true
}

// 校验身份证号
export const validateIdcar = (idcar) => {
  if (idcar != '') {
    var strRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
    if (!strRegex.test(idcar)) {
      return false
    }
  }
  return true
}


//校验只能字母和数字
export const validateAlphanumeric = (text) => {
  if (text != '') {
    var strRegex = /^[A-Za-z0-9]+$/
    if (!strRegex.test(text)) {
      return false
    }
  }
  return true
}

//校验只能数字
export const validateNumber = (text) => {
  if (text != '') {
    var strRegex = /^[0-9]+$/
    if (!strRegex.test(text)) {
      return false
    }
  }
  return true
}
