function Validator_CheckPassword(source, args) {
var result = true;
var password = $("#<%=txtPassword.ClientID %>").val();
if ($.trim(password) != '') {
if ($.trim(password).length < 6) {
result = false;
}
}
args.IsValid = result;
}
<td>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="160px" MaxLength="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
Text="*" ErrorMessage="请输入密码!" Display="None" ValidationGroup="1"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cvPassword" runat="server" ErrorMessage="密码长度必须控制在6-20位之间!"
Display="None" ValidationGroup="1" ClientValidationFunction="Validator_CheckPassword"></asp:CustomValidator>
<asp:HiddenField ID="hfPwd" runat="server" />
</td>