Password confirmation appears before entering a value in the text box

I wrote the following code on an aspx page in asp.net c # application

<section>
      <label>
         <asp:Label ID="lblPassword" runat="server" Text="Password *"></asp:Label></label>
      <label class="input">

                <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" data-content="Please Enter Your Password?" data-rel="popover" data-original-title="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvPassword" runat="server" Display="Dynamic" CssClass="state-error" ValidationGroup="profile" SetFocusOnError="true"
                    ControlToValidate="txtPassword">please enter password</asp:RequiredFieldValidator>
            </label>
        </section>

        <section>
            <label>
                <asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password *"></asp:Label></label>
            <label class="input">

                <asp:TextBox ID="txtConfrimPassword" TextMode="Password" runat="server" data-content="Please Confirm Your Password?" data-rel="popover" data-original-title="Confrim Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ValidationGroup="profile" SetFocusOnError="true"
                    CssClass="state-error" ControlToValidate="txtConfrimPassword">Please re-enter your password</asp:RequiredFieldValidator>
                <asp:CompareValidator runat="server" ID="valComPassword" CssClass="state-error" ControlToValidate="txtPassword" ControlToCompare="txtConfrimPassword"
                    Display="Dynamic" ValidationGroup="profile" SetFocusOnError="true" ErrorMessage="Confirm password does not match"></asp:CompareValidator>
            </label>
        </section>

Now the problem is when the user enters his password in the text box txtPassword, a confirmation (password confirmation) appears below the text box txtConfirmPassword. I want it to appear after the user enters their incorrect password in the text box txtConfirm.

+4
source share
2 answers

ControlToCompare txtConfrimPassword txtPassword, , txtPassword .

, .

<asp:CompareValidator runat="server" ID="valComPassword"  CssClass="state-error"  
    ControlToValidate="txtConfrimPassword" ControlToCompare="txtPassword" 
    Display="Dynamic" ValidationGroup="profile" SetFocusOnError="true" 
    ErrorMessage="Confirm password does not match">
</asp:CompareValidator>

, txtConfrimPassword. .

0

, :

<section>
    <asp:Label ID="lblPassword" runat="server" Text="Password *"></asp:Label>
    <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" data-content="Please Enter Your Password?" data-rel="popover" data-original-title="Password"></asp:TextBox>
    <asp:RequiredFieldValidator ID="rfvPassword" runat="server" Display="Dynamic" CssClass="state-error" ValidationGroup="profile" SetFocusOnError="true" ControlToValidate="txtPassword">please enter password</asp:RequiredFieldValidator>
</section>

<section>
    <asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password *"></asp:Label>
    <asp:TextBox ID="txtConfrimPassword" TextMode="Password" runat="server" data-content="Please Confirm Your Password?" data-rel="popover" data-original-title="Confrim Password"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ValidationGroup="profile" SetFocusOnError="true" CssClass="state-error" ControlToValidate="txtConfrimPassword">Please re-enter your password</asp:RequiredFieldValidator>
    <asp:CompareValidator runat="server" ID="valComPassword" CssClass="state-error" ControlToValidate="txtPassword" ControlToCompare="txtConfrimPassword" Display="Dynamic" ValidationGroup="profile" SetFocusOnError="true" ErrorMessage="Confirm password does not match"></asp:CompareValidator>
</section>
0

Source: https://habr.com/ru/post/1610405/


All Articles