function clsPassWordValidate(strPassWord) { this.passWord=strPassWord; this.errorTip=null; this.isSuccess=true; this.clsLengthValidate=clsPassWordValidate$clsLengthValidate; this.clsContentValidate=clsPassWordValidate$clsContentValidate; this.validate=clsPassWordValidate$validate; } function clsPassWordValidate$clsLengthValidate() {debugger; if(null==this.passWord) { this.isSuccess=false; this.errorTip="密码不允许为空!"; } else { if(this.passWord.length<1) { this.isSuccess=false; this.errorTip="密码长度不能少于1位!"; } } } function clsPassWordValidate$clsContentValidate() {debugger; var btest=/[A-Za-z]/.test(this.passWord); if(!btest) { this.isSuccess=false; this.errorTip="密码应该包含英文字母!"; } if(!this.isSuccess) { return; } btest=/[0-9]/.test(this.passWord); if(!btest) { this.isSuccess=false; this.errorTip="密码应该包含数字!"; } if(!this.isSuccess) { return; } btest=/[]\[\$~!@#%\^&\*\(\)_\+\{}\|:"<>\?`=\-\\;',\.\/]/.test(this.passWord); if(!btest) { this.isSuccess=false; this.errorTip="密码应该包含特殊字符!"; } } function clsPassWordValidate$validate() {debugger; this.clsLengthValidate(); if(this.isSuccess) { this.clsContentValidate(); } } function test() {debugger; var str="helloworld"; var oValidate=new clsPassWordValidate(str); oValidate.validate(); if(!oValidate.isSuccess) { alert(oValidate.errorTip); } } test();