/**
* 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;
}
新聞熱點
疑難解答
圖片精選