I am employing client-side validation. From the example above, we found that they use both validation on client-side and server side functions. Can we remove OnServerValidate from CustomValidator?
I am employing client-side validation. From the example above, we found that they use both validation on client-side and server side functions. Can we remove OnServerValidate from CustomValidator?
Yes can remove OnServerValidate, here is the simple example, which demostrates, if the user enters more than 6 characters
zhshqzyc
Member
416 Points
517 Posts
Duplicated
Apr 23, 2012 03:33 PM|LINK
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx
I am employing client-side validation. From the example above, we found that they use both validation on client-side and server side functions. Can we remove OnServerValidate from CustomValidator?
2pac
Participant
1586 Points
269 Posts
Re: Duplicated
Apr 24, 2012 02:08 AM|LINK
Yes can remove OnServerValidate, here is the simple example, which demostrates, if the user enters more than 6 characters
is fired and returns "args.IsValid = false":
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="jquery-1.7.1.js"></script> <script type="text/javascript"> function ValidateUserName(source, args) { var textBox = $('#<%= TextUserName.ClientID%>').val(); if (textBox.length > 6) { args.IsValid = false; return false; } args.IsValid = true; return true; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextUserName" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidatorUser" runat="server" ControlToValidate="TextUserName" ErrorMessage="Minimum of 6 (six) alphanumeric characters." ClientValidationFunction="ValidateUserName" Display="Dynamic" ValidateEmptyText="True"></asp:CustomValidator> </div> </form> </body> </html>Regards,
Jayesh