gpt4 book ai didi

c# - .net 验证

转载 作者:太空宇宙 更新时间:2023-11-03 22:07:29 25 4
gpt4 key购买 nike

我在 .net 中构建的网站上工作,但在“验证”方面遇到了一些麻烦

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
ErrorMessage="<p>Invalid Phone Number!</p>"........

这是用内联样式在页面上发布一条消息,我需要它做的是向输入字段添加一个类,这可能吗?

最佳答案

我建议为此使用 CustomValidator:

http://msdn.microsoft.com/en-us/library/9eee01cx(v=VS.100).aspx

<asp:CustomValidator id="CustomValidator1"
ControlToValidate="Text1"
ClientValidationFunction="ClientValidate"
ErrorMessage="<p>Invalid Phone Number!</p>"
runat="server"/>


<script language="javascript">
function ClientValidate(source, arguments)
{
var regexValid = false; // perform regular expression validation here manually
if (regexValid) {
arguments.IsValid=true;
}
else {
// add the class to the desired input field
arguments.IsValid=false;
}
}
</script>

关于c# - .net 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7877283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com