📄 validate.js
字号:
//----------------------------------------------------------------------------
/* function: to validate the Client input data type and length
param1(required): sToVerify -- String to be verified
param2(required): iBinLenReqest -- Number of Binary Length of the String to be verified
send 0 if no limit
return: --String, passed verified of length and replace of "'" to "’"
--False, not passed
*/
function ClientInputVerify(sToVerify, iBinLenRequest){
if(iBinLenRequest.NaN){return false;}
var arrElm;
sToVerify=sToVerify.replace(/[']/g,"’");
sToVerify=sToVerify.replace(/["]/g,"”");
sToVerify=sToVerify.replace(/[%]/g,"%");
sToVerify=sToVerify.replace(/[&]/g,"·");
sToVerify=sToVerify.replace(/[*]/g,"*");
sToVerify=sToVerify.replace(/[(]/g,"(");
sToVerify=sToVerify.replace(/[)]/g,")");
sToVerify=sToVerify.replace(/\[/g,"[");
sToVerify=sToVerify.replace(/\]/g,"]");
sToVerify=sToVerify.replace(/[<]/g,"〈");
sToVerify=sToVerify.replace(/[>]/g,"〉");
sToVerify=sToVerify.replace(/[?]/g,"?");
arrElm = sToVerify.split("");
var iBinLen = new Number(0);
for(i=0;i<arrElm.length;i++){
if(arrElm[i].charCodeAt()>255){
iBinLen+=2;
}
else{iBinLen++}
}
if((iBinLen>iBinLenRequest)&&iBinLenRequest!=0){
return false;
}
else{
return sToVerify;
}
}
//----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -