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

x
?
Solved

regularexpressionvalidator  and requiredfieldvalidator

Posted on 2013-01-31
7
Medium Priority
?
245 Views
Last Modified: 2013-02-22
Is there a way to use regularexpressionvalidator  and requiredfieldvalidator on a single textbox?
0
Comment
Question by:VBdotnet2005
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38840382
You can have more than one validator control to validate a single textbox you simply add both validator controls and set the ControlToValidate attribute on both validator controls to the textbox id.
0
 

Author Comment

by:VBdotnet2005
ID: 38840487
Do I need to use "Display = "Dynamic"?  I want the message to display either message.

*invalid $ amount or *Required field
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38840545
The Display attribute determines whether the validation controls have space allocated on the page for them or they are added to the page when the failure occurs.

Generally you would set Display= Dynamic so that you don't have empty space on the page.
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:VBdotnet2005
ID: 38840584
I tried below. It still postback when txtprice is empty. It does display "*required" though.

<asp:TextBox ID="txtprice" runat="server"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtprice" ErrorMessage="Incorrect Amount" ValidationExpression="^-?([1-9]\d*|(\d+))(\.\d{2})$" ValidationGroup="Group_price" Display="Dynamic"></asp:RegularExpressionValidator><asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtprice" ErrorMessage="*Required" ValidationGroup="Group_price" Display="Dynamic"></asp:RequiredFieldValidator>
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38840803
Have you set the ValidationGroup property for the submit button?

Also check if there are any other javascript errors on the page using Firebug plugin for Firefox. If there are any javascript errors on the page, then the page will postback.
0
 
LVL 10

Accepted Solution

by:
Monica P earned 2000 total points
ID: 38846563
u may get sample here to fix it off

http://forums.asp.net/t/1852836.aspx/1
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38918778
Wow. Looks like I should have shown you an example instead of asking you a question. Very good. It's a lesson for me. Thanks @VBdotnet2005
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 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