Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:56:39+00:00 2026-06-13T07:56:39+00:00

I want to validate the textbox on text change event. When i click on

  • 0

I want to validate the textbox on text change event. When i click on the button, and enter any invalid address, the Invalid Email Address Error occurs firstly and then immediately hides.

I also have an isRecordAlreadyExist Function, this function checks the duplicate values exist in the database. I want this checking to be performed at textchanged event. But the event Dosent gets fired. and the value is not checked.
My Code:

<tr>
            <td style="padding-top: 20px;">
                Email Address<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                    ErrorMessage="*" ControlToValidate="txtEmail" ForeColor="Red" ValidationGroup="val" Display="Dynamic"></asp:RequiredFieldValidator>
            </td>
            <td style="padding-top: 20px;">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <asp:TextBox ID="txtEmail" runat="server" OnTextChanged="txtEmail_TextChanged" AutoPostBack="true"></asp:TextBox><asp:RegularExpressionValidator
                            ID="regexEmail" runat="server" ErrorMessage="Invalid Email Address" ControlToValidate="txtEmail"
                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ForeColor="Red"
                            ValidationGroup="">
                        </asp:RegularExpressionValidator>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
<tr>
            <td style="padding-top: 10px;">
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btnSubmitCSS" OnClick="btnSubmit_Click"
                    ValidationGroup="val" OnClientClick="return chk_isValid();" />
                <asp:Button ID="btnReset" runat="server" CausesValidation="False" Text="Reset" CssClass="btnSubmitCSS"
                    OnClick="btnReset_Click" />
            </td>
        </tr>

My Code Behind..

protected bool isRecordAlreadyExist(TextBox txt_Value, int res)
{
    ds = new DataSet();
    paramArray = new string[3, 2];
    paramArray[0, 0] = "@uname";
    paramArray[0, 1] = txtuname.Text.Trim();
    paramArray[1, 0] = "@emailid";
    paramArray[1, 1] = txtEmail.Text.Trim();
    paramArray[2, 0] = "`";
    obj = new DalLib();
    ds = obj.getDataSet("sp_Tbl_Login_MatchValues", paramArray);
    gvLogin.DataSource = ds.Tables[res].DefaultView;
    if (ds.Tables[res].Rows.Count > 0)
    {
        mtvResult.ActiveViewIndex = 3;
        btnSubmit.Enabled = false;
        return false;
    }
    else
    {
        btnSubmit.Enabled = true;
        return true;
    }
}

my asp:View Control:

<asp:View ID="vAlreadyExist" runat="server">
            <img src="Images/delete.png" alt="Edit" />
            <asp:Label ID="lblAlreadyExist" runat="server">Record Already Exist</asp:Label>
        </asp:View>


protected void btnSubmit_Click(object sender, EventArgs e)
    {

        if (ViewState["action"].ToString() == "Insert")
        {
            obj = new DalLib();
            paramArray = new string[7, 2];
           // if (!string.IsNullOrEmpty(txtFullName.Text.Trim()))
            {
                paramArray[0, 0] = "@FullName";
                paramArray[0, 1] = txtFullName.Text.Trim();
            }

            //if (!string.IsNullOrEmpty(txtuname.Text.Trim()))
            {

                paramArray[1, 0] = "@uname";
                paramArray[1, 1] = txtuname.Text.Trim();
            }
            //if (!string.IsNullOrEmpty(txtPwd.Text.Trim()))
            {
                paramArray[2, 0] = "@pwd";
                paramArray[2, 1] = txtPwd.Text.Trim();
            }
            //if (!string.IsNullOrEmpty(txtEmail.Text.Trim()))
            {
                paramArray[3, 0] = "@emailid";
                paramArray[3, 1] = txtEmail.Text.Trim();
            }

            paramArray[4, 0] = "@isAdmin";
            paramArray[4, 1] = chkAdmin.Checked.ToString();

            paramArray[5, 0] = "@isActive";
            paramArray[5, 1] = chkActive.Checked.ToString();
            paramArray[6, 0] = "`";
            result = obj.setData("sp_Tbl_Login_Insert", paramArray);
            LoadData();
            EmptyFields();
            mtvResult.ActiveViewIndex = 0;
        }

}

protected void txtEmail_TextChanged(object sender, EventArgs e)
{
    isRecordAlreadyExist(txtEmail, 1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:56:40+00:00Added an answer on June 13, 2026 at 7:56 am

    You are mixing client validation with server. You have AutoPostBack="true" for textbox. The regularExpression checks the validation on client and does not need AutoPostBack. You need server validation when button is clicked. Removing AutoPostBack from text box will cause client validation to check the email format on blur of textbox and server validation will be done on button click. Also remove OnTextChanged="txtEmail_TextChanged" from textbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text box and i want to validate is valid email in textbox
here i want to validate few textboxes by Element Finding on button Click event
I want to validate my email address through jquery unobtrusive validation . Like to
I'm using a TextBox to enter user's name, here I want to validate that
If I want to validate that a text box contains an integer greater than
basically I want to validate whether or not a text box is a certain
I have an asp:TextBox and I want to validate that the number of characters
I want to validate a form fields (text) input. It should only be a
i have asp text box and button control. <asp:TextBox ID=txtFName runat=server CssClass=sfInputbox></asp:TextBox> <asp:Button runat=Server
I want to validate some text boxes in my ASP.NET page using ASP required

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.