Solved

RegularExpressionValidator ErrorMessage not cleared.

Posted on 2008-06-17
9
1,304 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb. Net application freezes 9 31
Exit the loop 4 40
Close form "before" open 3 30
Run a batch file when a Crystal Report is opened 5 16
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now