自己做的网页怎么上传到网站吗,网站建设技术知乎,企业做网站价钱,西宁网络信息 网站建设uView内置了一些校验规则#xff0c;如是否手机号#xff0c;邮箱号#xff0c;URL等 这些规则方法#xff0c;挂载在$u.test下面#xff0c;如验证是否手机号#xff1a;$u.test.mobile(13888889999)#xff0c;如果验证通过#xff0c;返回true#xff0c;否则返回f…uView内置了一些校验规则如是否手机号邮箱号URL等 这些规则方法挂载在$u.test下面如验证是否手机号$u.test.mobile(13888889999)如果验证通过返回true否则返回false
#是否验证码
#code(value, len 6)
校验是否验证码(要求为数字)返回true或者false。
value String 验证码字符串len Number 验证码长度默认为6
console.log(uni.$u.test.code(4567, 4));copy
#是否数组
#array(array)
校验是否数组返回true或者false。
array Array 数组
console.log(uni.$u.test.array([1, 2, 3]));copy
#是否Json字符串
#jsonString(json)
校验是否数组返回true或者false。
json Json Json字符串
注意请留意json字符串的要求
整体为一个字符串字符串对象内的属性需要用双引号包含
console.log(uni.$u.test.jsonString({a: 1}));copy
#是否对象
#object(object)
校验是否数组返回true或者false。
object Object 对象
console.log(uni.$u.test.object({a: 1}));copy
#是否邮箱号
#email(email)
校验是否邮箱号返回true或者false。
email String 字符串
console.log(uni.$u.test.email(123465798gmail.com));copy
#是否手机号
#mobile(mobile)
校验是否手机号返回true或者false。
mobile String 字符串
console.log(uni.$u.test.mobile(13845678900));copy
#是否URL
#url(url)
校验是否URL链接返回true或者false。
url String 字符串
console.log(uni.$u.test.url(http://www.uviewui.com));copy
#是否为空
这里指的“空”包含如下几种情况
值为undefined(一种类型)非字符串undefined字符串长度为0也即空字符串值为false(布尔类型)非字符串false值为数值0(非字符串0)或者NaN值为null空对象{}或者长度为0的数组
#isEmpty(value)
校验值是否为空返回true或者false。 此方法等同于empty名称但是为了更语义化推荐用isEmpty名称。
value any 字符串
console.log(uni.$u.test.isEmpty(false));copy
#是否普通日期
验证一个字符串是否日期返回true或者false如下行为正确
2020-02-10、2020-02-10 08:32:10、2020/02/10 3:10、2020/02/10 03:10、2020/02-10 3:10
如下为错误
2020年02月10日、2020-02-10 25:32
总的来说年月日之间可以用/或者-分隔(不能用中文分隔)时分秒之间用:分隔数值不能超出范围如月份不能为13则检验成功否则失败。
#date(date)
date String 日期字符串
console.log(uni.$u.test.date(2020-02-10 08:32:10));copy
#是否十进制数值
整数小数负数带千分位数(2,359.08)等可以检验通过返回true或者false。
#number(number)
number String 数字
console.log(uni.$u.test.number(2020));copy
#是否整数
所有字符都在0-9之间才校验通过结果返回true或者false。
#digits(number)
number String 数字
console.log(uni.$u.test.digits(2020));copy
#是否身份证号
身份证号包括尾数为X的类型可以校验通过结果返回true或者false。
#idCard(idCard)
idCard String 身份证号
console.log(uni.$u.test.idCard(110101199003070134));copy
#是否车牌号
可以校验旧车牌号和新能源类型车牌号结果返回true或者false。
#carNo(carNo)
carNo String 车牌号
console.log(uni.$u.test.carNo(京A88888));copy
#是否金额
最多两位小数可以带千分位结果返回true或者false。
#amount(amount)
amount String 金额字符串
console.log(uni.$u.test.amount(3,233.08));copy
#是否汉字
可以为单个汉字或者汉字组成的字符串结果返回true或者false。
#chinese(zh)
zh String 中文字符串
console.log(uni.$u.test.chinese(更上一层楼));copy
#是否字母
只能为a-z或者A-Z之间的字符结果返回true或者false。
#letter(en)
en String 字母串
console.log(uni.$u.test.letter(uView));copy
#是否字母或者数字
只能是字母或者数字结果返回true或者false。
#enOrNum(str)
str String 字母或者数字字符串
console.log(uni.$u.test.enOrNum(uView));copy
#是否包含某个值
字符串中是否包含某一个子字符串区分大小写结果返回true或者false。
#contains(str, subStr)
str String 字符串subStr String 子字符串
console.log(uni.$u.test.contains(uView, View));copy
#数值是否在某个范围内
如30在29-35这个范围内不在25-28这个范围内结果返回true或者false。
#range(number, range)
number Number 数值range Array 如[25-35]
console.log(uni.$u.test.range(35, [30, 34]));copy
#字符串长度是否在某个范围内
如abc长度为3范围在2-5这个区间结果返回true或者false。
#rangeLength(str, range)
str String 数值range Array 如[25, 35]
console.log(uni.$u.test.rangeLength(abc, [3, 10]));