Solved

regularexpressionvalidator  and requiredfieldvalidator

Posted on 2013-01-31
7
234 Views
Last Modified: 2013-02-22
Is there a way to use regularexpressionvalidator  and requiredfieldvalidator on a single textbox?
0
Comment
Question by:VBdotnet2005
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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