5
Answers

using custom validator to validate an regular expression

manjula d

manjula d

11y
4.9k
1
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)