密码验证 长度八位包含字母数字特殊字符
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #region 密码验证 2 if (tbPassword.Text == "") 3 { 4 CommonFunction.ShowMessage(this.Page, "密码不能为空"); 5 return; 6 } 7 if (tbPassword.Text.Length < 8) 8 { 9 CommonFunction.ShowMessage(this.Page, "密码长度不能小于8"); 10 return; 11 } 12 if (CommonFunction.IsMatchRight(tbPassword.Text, "[a-z]")==false) 13 { 14 CommonFunction.ShowMessage(this.Page,"密码必须包含字母"); 15 return; 16 } 17 if (CommonFunction.IsMatchRight(tbPassword.Text, "[0-9]")==false) 18 { 19 CommonFunction.ShowMessage(this.Page, "密码必须包含数字"); 20 return; 21 } 22 if (CommonFunction.IsMatchRight(tbPassword.Text, "[^a-z0-9]")==false) 23 { 24 CommonFunction.ShowMessage(this.Page, "密码必须包含特殊字符"); 25 return; 26 } 27 #endregion