Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RegularExpressionValidator ErrorMessage not cleared.

Posted on 2008-06-17
9
Medium Priority
?
1,392 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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