javascript与php验证类
2021-07-20 23:09
标签:bool https rip www. var test log www false 二、php: javascript与php验证类 标签:bool https rip www. var test log www false 原文地址:http://blog.51cto.com/12173069/2162625
function filter(){
this.isvalidurl = function(data){
if(/^((http|ftp|https):\/\/)?[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/.test(data)){
return true;
}else{
return false;
}
}
this.isvalidemail = function(data){
if(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(data)){
return true;
}else{
return false;
}
}
this.isvalidtel = function(data){
if(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(data)){
return true;
}else{
return false;
}
}
}
// var filter = new filter()
// var ret = filter.isvalidurl(‘https://www.baidu.com‘)
// console.log(ret)
true
[Finished in 0.3s]
isvalidurl(‘https://www.baidu.com‘);
// var_dump($ret);
bool(true)
[Finished in 0.1s]
文章标题:javascript与php验证类
文章链接:http://soscw.com/index.php/essay/106775.html