1 <script language="javascript" type="text/javascript">
2
3 function getLength(str) {
4 var len = str.length;
5 var reLen = 0;
6 for (var i = 0; i < len; i++) {
7 if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
8 // 全角
9 reLen += 2;
10 } else {
11 reLen++;
12 }
13 }
14 return reLen;
15 }
16
17
18
19
20
21 function ChkFrm() {
22
23
24 var txtTrueName = document.getElementById("TxtTitle"); //用户姓名
25 if (getLength(txtTrueName.value) > 6) {
26 alert("长度不能小于6");
27 txtTrueName.focus();
28 return false;
29 }
30 return true;
31 }
32 </script>