Posted in Javascript onMarch 19, 2014
<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>
效果如图:
js判断字符长度及中英文数字等
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@