Solved

How to make custom validations of a requiredfieldvaildator control ?

Posted on 2008-10-20
1
351 Views
Last Modified: 2008-10-20
HI

A form contains a couple of controls (textbox) that have associated a RequiredFieldValidator, I need to make mandatory just one at the time but it depends on the button clicked (there are two buttons too).

Something like this:

if BUTTON_A was pressed then
     TEXTBOX_A must be mandatory and TEXTBOX_B doesn´t matter
else
    viceversa
endif

Thanks.
0
Comment
Question by:dimensionav
1 Comment
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 250 total points
ID: 22761472
<asp:TextBox id="txtA" runat="server"/>
<asp:RequieredFieldValidator id="rfvA" runat="server" ControlToValidate="txtA" ValidationGroup="GroupA"/>

<asp:TextBox id="txtB" runat="server"/>
<asp:RequieredFieldValidator id="rfvB" runat="server" ControlToValidate="txtB" ValidationGroup="GroupB"/>

<asp:Button id="cmdA" runat="server" ValidationGroup="GroupA"/>
<asp:Button id="cmdB" runat="server" ValidationGroup="GroupB"/>

You must use validation groups
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

821 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