Home >Web Front-end >JS Tutorial >js sends a function to determine whether a string meets the standard_javascript skills

js sends a function to determine whether a string meets the standard_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:53:411310browse
复制代码 代码如下:

function ZQH_isIP(str){
var arrIP = str.split(".");
if(arrIP.length != 4){
return false;
} else {
var i;
for(i in arrIP)
{
if(ZQH_isNumeric(arrIP[i]))
{
if(arrIP[i] < 0 || arrIP[i] > 255){
return false;
}
} else {
return false;
}
}
}
return true;
}

function ZQH_isNumeric(str){
if(str.length == 0){
return false
}
for(var i=0; iif(str.charAt(i) < "0" || str.charAt(i) > "9"){
return false;
}
}
return true;
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn