js判断字符长度及中英文数字等
更新时间:2014年03月19日 11:50:46 投稿:whsnow
这篇文章主要介绍了js判断字符长度及中英文数字等,需要的朋友可以参考下
复制代码 代码如下:
<script type="text/javascript">
var zfl={};
zfl.GetLength = function(str){
var realLength = 0,len = str.length,charCode = -1;
for(var i=0;i<len;i++){
charCode = str.charCodeAt(i);
if(charCode>0 && charCode<=128) realLength +=1;
else realLength += 2;
else realLength += 2;
else realLength += 2;
<script type="text/javascript">
alert(zfl.GetLength("中国123zkrljl"));
</script>
效果如图:
相关文章
function, new function, new Function之间的区别
function, new function, new Function之间的区别...2007-03-03


最新评论