/**
* rief 求得一个字符串的ANSI字符串长度
* param value 传入的UNICODE字符串
* eturn 返回字符串的ANSI字符串长度
*/
function ByteWordCount(value) {
var txt = value;
txt = txt.replace(/(<.*?>)/ig,'');
txt = txt.replace(/([u0391-uFFE5])/ig,'11');
return txt.length;
}
/**
* rief 判断一个字符是否是字母
* param ch 要判断的字符
* eturn true 是 false 不是
*/
function isAlpha(ch) {
if(ch >= "a" && ch <= "z") return true;
if(ch >= "A" && ch <= "Z") return true;
return false;
}
/**
* rief 判断一个字符是否是数字
* param ch 要判断的字符
* eturn true 是 false 不是
*/
function isNumber(ch) {
if(ch >= "0" && ch <= "9") return true;
return false;
}
/**
* rief 判断一个字符是否是可打印标点符号
* param ch 要判断的字符
* eturn true 是 false 不是
*/
function isSpecial(ch) {
var special = new Array("!","""","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","/","]","^","_","`","{","|","}","~")
for(var i=0;i<special.length;++i)
if(ch == special[i]) return true;
return false;
}
function CheckValidStr(value)
{
var count=0;
for(var i=0;i<value.length;++i)
{
var ch = value.charAt(i);
if(isAlpha(ch)||isNumber(ch)||isSpecial(ch))
count++;
else
count=0;
if(count>20)
{
return false;
}
}
return true;
}
新闻热点
疑难解答
图片精选