1.checkpassword = function(v){
2. var numasc = 0;
3. var charasc = 0;
4. var otherasc = 0;
5. if(0==v.length){
6. return "密码不能为空";
7. }else if(v.length<8||v.length>12){
8. return "密码至少8个字符,最多12个字符";
9. }else{
10. for (var i = 0; i < v.length; i++) {
11. var asciiNumber = v.substr(i, 1).charCodeAt();
12. if (asciiNumber >= 48 && asciiNumber <= 57) {
13. numasc += 1;
14. }
15. if ((asciiNumber >= 65 && asciiNumber <= 90)||(asciiNumber >= 97 && asciiNumber <= 122)) {
16. charasc += 1;
17. }
18. if ((asciiNumber >= 33 && asciiNumber <= 47)||(asciiNumber >= 58 && asciiNumber <= 64)||(asciiNumber >= 91 && asciiNumber <= 96)||(asciiNumber >= 123 && asciiNumber <= 126)) {
19. otherasc += 1;
20. }
21. }
22. if(0==numasc) {
23. return "密码必须含有数字";
24. }else if(0==charasc){
25. return "密码必须含有字母";
26. }else if(0==otherasc){
27. return "密码必须含有特殊字符";
28. }else{
29. return true;
30. }
31. }
32.};