Solved

regularexpressionvalidator  and requiredfieldvalidator

Posted on 2013-01-31
7
232 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
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.

 

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

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

937 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

6 Experts available now in Live!

Get 1:1 Help Now