Link to home
Start Free TrialLog in
Avatar of swech
swech

asked on

Comparing two password fields in asp.net


                                                Pasword<asp:textbox id="txtPassword" class="textarea" textmode="password" runat="server"/>
                                                <asp:requiredfieldvalidator id="validatePassword" runat="server" errormessage="<br/>Please Enter Password. " controltovalidate="txtPassword" display="dynamic"/>
                                                <asp:RegularExpressionValidator runat="server" ControlToValidate="txtPassword" ValidationExpression="[0-9a-zA-Z]{5,10}" ErrorMessage= "<br/>Login Id should be 5 to 10 characters or numbers." display="dynamic"/>

Repassword                                                <asp:textbox id="txtRePassword" class="textarea" textmode="password" runat="server"/>
                                                <asp:requiredfieldvalidator id="validaterePassword" runat="server" errormessage="<br/>Please Enter Re-Password. " controltovalidate="txtRePassword" display="dynamic"/>
                                                <asp:RegularExpressionValidator runat="server" ControlToValidate="txtRePassword" ValidationExpression="[0-9a-zA-Z]{5,10}" ErrorMessage= "<br/>Login Id should be 5 to 10 characters or numbers." display="dynamic"/>
                                                <asp:CompareValidator
                                                 ControlToValidate="txtPassword"
                                                 ControlToCompare="txtRePassword"
                                                 Display="Dynamic"
                                                 Text="<br/>Password and Re-Password does not match."
                                                 Runat="Server" />

I'm try to compare two password field from the above code.the code is working fine the only problem is that.
when the form loads it is obvious that both fields are blank.And when i type in the Password field and move to the next Re-password field that without me typing anything in Re-password field it already compares the value and gives me the Error msg (Password and Re-Password does not match.).

should it compare the values in the two textbox only after i've typed on both the text boxes or when i click the button.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swech
swech

ASKER

thanks for quick response.