manjula d

manjula d

  • NA
  • 172
  • 140.3k

using custom validator to validate an regular expression

Jun 3 2013 6:08 AM
hello sir,

by using custom validator to validate an regular expression with email id how to write a code in OnServerValidate propertie anybody can help me to solve please................
below of my code is:

Client Side Javascript:

function ValidateEmailId(source, args) {
          var rdbemailid = document.getElementById("<%=rdb_No.ClientID %>");
          var emilid = $("#<%= txtEmail.ClientID %>").val();
           if (rdbemailid.checked) {
          if (emilid == "") {
                   args.IsValid = false;
              }
              else {
                   args.IsValid = true;
              }
           }

       }
<asp:TextBox ID="txtEmail" runat="server"/>

<asp:CustomValidator ID="cvemail" runat="server" ClientValidationFunction = "ValidateEmailId" OnServerValidate = "validateserver" Text="Please Enter EmailId" ControlToValidate="txtEmail" ValidateEmptyText="true" ErrorMessage="Please Enter Valid EmailId" ForeColor="Red"></asp:CustomValidator>

Answers (5)