69 lines
1.4 KiB
JavaScript
69 lines
1.4 KiB
JavaScript
// 正则验证
|
|
//检查非空验证
|
|
function isNull(str1, str2, str3, str4) {
|
|
if (str1 == '' || str2 == '' || str3 == '' || str4 == '') {
|
|
uni.showToast({
|
|
title: '请完善信息',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
});
|
|
return false;
|
|
} else {
|
|
isNull.prototype.the_Null = true // 添加新属性,建立标识
|
|
return true
|
|
}
|
|
}
|
|
// 检查手机号码格式是否正确
|
|
function isPhone(str) {
|
|
// var reg = /^[1][3,4,5,7,8][0-9]{9}$/;
|
|
//ver reg = '/^1[0-9]{10}$/';
|
|
var reg = /^1\d{10}$/;
|
|
if (reg.test(str)) {
|
|
isPhone.prototype.the_isPhone = true // 添加新属性,建立标识
|
|
return true;
|
|
} else {
|
|
uni.showToast({
|
|
title: '请输入正确的手机号',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
// 检查是否有汉字 /[\u4E00-\u9FA5]/g
|
|
function isUniCode(str){
|
|
var reg = /[\u4E00-\u9FA5]/g;
|
|
if (reg.test(str)) {
|
|
uni.showToast({
|
|
title: '不得出现汉字',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
});
|
|
return false;
|
|
} else {
|
|
isUniCode.prototype.the_isUniCode = true // 添加新属性,建立标识
|
|
return true;
|
|
|
|
}
|
|
}
|
|
// 检查两次密码输入是否一样
|
|
function isSamePsd(str1,str2) {
|
|
if(str1 === str2 && str1!='' && str2!=''){
|
|
isSamePsd.prototype.the_isSamePsd = true // 添加新属性,建立标识
|
|
return true
|
|
}else{
|
|
uni.showToast({
|
|
title: '请输入相同的密码',
|
|
duration: 2000,
|
|
icon: 'none'
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
export default {
|
|
isNull,
|
|
isPhone,
|
|
isSamePsd,
|
|
isUniCode
|
|
}
|