【发布时间】:2023-03-07 01:19:01
【问题描述】:
我在向导视图中使用 js 函数创建了 CustomValidator,只是为了检查密码长度。 而且他不工作,对不起我的新手。
js函数:
<script type="text/javascript">
function clientValidate(sender, args) {
if (args.Value.length < 5 ||args.Value.length > 30) {
args.IsValid = false;
}
}
</script>
asp 字段:
<asp:TextBox ID="tbPassword1" runat="server" TextMode="Password"></asp:TextBox>
<asp:CustomValidator ID="CustomValidatorPassLength" runat="server" display="Dynamic" ControlToValidate="tbPassword1" ClientValidationFunction="clientValidate" ErrorMessage="Slaptažodis turi būti nuo 5 iki 30 simbolių ilgio." ForeColor="Red"></asp:CustomValidator>
谢谢,对不起!
【问题讨论】:
-
文本框为空时是否要触发验证功能?还是根本不起作用?
-
从空文本框 requiredfield 验证器保护,我想在 tbPassword1.text.length 小于 5 且超过 30 个符号时触发 js 函数。
标签: javascript asp.net customvalidator