Telerik 控件 RasMaskedTextBox 未显示错误消息
Telerik control RasMaskedTextBox is not showing error message
我正在为 Telerik 使用 CustomValidator RadMaskedTextbox.The 问题是如果我不输入任何值,它不会显示错误消息。
<telerik:RadMaskedTextBox ID="RadMaskedTextBox3" runat="server"
Width="150"
Mask="(###) ###-#### ext. #####">
</telerik:RadMaskedTextBox>
<asp:CustomValidator ID="CustomValidator4" runat="server"
ErrorMessage="*"
Display="Dynamic"
CssClass="error1"
Enabled="false"
ToolTip="At least one Phone no: needs to be filled in."
ValidateEmptyText="true"
EnableClientScript="true"
OnServerValidate="CustomValidator_ServerValidate"
SetFocusOnError ="true"
ValidationGroup="CarrierBaseInformation1">
</asp:CustomValidator>
以下是如何实现您的目标的示例:
在Web.config组
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
在aspx中
<telerik:RadMaskedTextBox Mask="(###) ###-#### ext. #####" RenderMode="Lightweight" ID="RadMaskedTextBox1" runat="server" EmptyMessage="Enter username"></telerik:RadMaskedTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="*" ControlToValidate="RadMaskedTextBox1"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="PostBack" />
这是另一个带有 CustomValidator 的示例:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="CheckLength"
ErrorMessage="Phone\Fax numbers must be 7 or 9 digits"
ControlToValidate="txtTollFree">*</asp:CustomValidator>
<script>
function CheckLength(source, args)
{
if (args.Value.length == 10 || args.Value.length == 13)
{
args.IsValid = true;
}else{
args.IsValid = false;
}
}
</script>
我正在为 Telerik 使用 CustomValidator RadMaskedTextbox.The 问题是如果我不输入任何值,它不会显示错误消息。
<telerik:RadMaskedTextBox ID="RadMaskedTextBox3" runat="server"
Width="150"
Mask="(###) ###-#### ext. #####">
</telerik:RadMaskedTextBox>
<asp:CustomValidator ID="CustomValidator4" runat="server"
ErrorMessage="*"
Display="Dynamic"
CssClass="error1"
Enabled="false"
ToolTip="At least one Phone no: needs to be filled in."
ValidateEmptyText="true"
EnableClientScript="true"
OnServerValidate="CustomValidator_ServerValidate"
SetFocusOnError ="true"
ValidationGroup="CarrierBaseInformation1">
</asp:CustomValidator>
以下是如何实现您的目标的示例:
在Web.config组
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
在aspx中
<telerik:RadMaskedTextBox Mask="(###) ###-#### ext. #####" RenderMode="Lightweight" ID="RadMaskedTextBox1" runat="server" EmptyMessage="Enter username"></telerik:RadMaskedTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="*" ControlToValidate="RadMaskedTextBox1"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="PostBack" />
这是另一个带有 CustomValidator 的示例:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="CheckLength"
ErrorMessage="Phone\Fax numbers must be 7 or 9 digits"
ControlToValidate="txtTollFree">*</asp:CustomValidator>
<script>
function CheckLength(source, args)
{
if (args.Value.length == 10 || args.Value.length == 13)
{
args.IsValid = true;
}else{
args.IsValid = false;
}
}
</script>