Solved

regularexpressionvalidator  and requiredfieldvalidator

Posted on 2013-01-31
7
237 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hbo knew my windows software 4 75
FInd Image Control Gridview 3 33
Why use this lambda? 12 60
vb.net, web page, SQL holding the selected data in an accessible variable 7 32
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 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