Solved

RegularExpressionValidator ErrorMessage not cleared.

Posted on 2008-06-17
9
1,345 Views
Last Modified: 2010-09-14
I have the following code to validate creditcard using RegularExpressionValidator. When I enter a valid credit card no 1111111111111111, it doesn't show an error message which is good. When I enter an invalid credit card no 11, it does show the error message which is also good. But the problem I have is when I enter back the credit card no 1111111111111111, it doesn't clear the error message. If I delete the credit card no, it clears the error message and when I enter back 1111111111111111, it doesn't show any error message.

<asp:TextBox Columns="35" CssClass="Content" ID="CreditCardNumber" MaxLength="19" Runat="server"/>
<asp:RegularExpressionValidator ID="regExCreditCardNumber" runat="server"
                            ControlToValidate="CreditCardNumber" Display="Dynamic" ValidationExpression="Some Expression" ErrorMessage="Please enter a valid Credit Card Number" />
0
Comment
Question by:sandya_116
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 21804364
>>>But the problem I have is when I enter back the credit card no 1111111111111111, it doesn't clear the error message.
Remember, thought, you cursor has to leave the textbox in order for the validator to work.
0
 

Author Comment

by:sandya_116
ID: 21804495
The cursor is leaving the textbox. I am in another control. But still the error message doesn't clear up.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 21804758
I copied and pasted your code in my web application, and I didn't have any problem to run the application. The error message cleared up as I followed the steps you specified in your question.
I would try to set MaxLength=16 so that I would not mistakenly enter more digits in the textbox. You know, it is hard to tell if there are 16 "1"s or 17 "1"s in the textbox.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:sandya_116
ID: 21805158
Now that I looked at it more, I found that the problem comes only when user selects an already typed in number. I made sure that it was 16 digits. If I retype the number, the error message clears up. I am not sure why the error doesn't clear up, if select an existing number.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 21805663
>>>if select an existing number.
How do you select a number for the textbox? Are you talking about the history data?
0
 

Author Comment

by:sandya_116
ID: 21805837
Yes I am talking about the history data.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 21805907
That might be the problem.
0
 

Author Comment

by:sandya_116
ID: 21806422
Is there anything I can do for this problem?
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 21806570
Are you using .NET 2.0 and Visual Studio 2005? If yes, then there is a property for the textbox called "AutoCompleteType", you can set it to Disabled. It will prevent the textbox from remembering the data previously entered.

If not, then you need to add this line in your code to do the same thing above:
CreditCardNumber.Attributes.Add("autocomplete", "off")
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question