Here I will explain how to use customer validator in a asp.net project to validate a controls.
<head runat="server"> <title></title> <script type="text/javascript" language="javascript"> function
IsEven(source, args) { if
(args.Value % 2 == 0) { args.IsValid = true;} else
{ args.IsValid = false;} } </script></head>
<div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="please enter even no" ClientValidationFunction="IsEven"></asp:CustomValidator> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="IsEven" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
Customervalidator (Server side)
0 comments::
Post a Comment