﻿//----------------------------------------------------------------------------
/* 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;
	}
}
//----------------------------------------------------------------------------
