Groups | Blog | Home
all groups > asp.net webcontrols > january 2004 >

asp.net webcontrols : Validate only one textbox value



raypolee NO[at]SPAM yahoo.com
1/30/2004 4:37:05 PM
Hi,

I have 5 textbox fields and only one (required one) is allowed to
contains value when sumbit. Any idea?

Peter Blum
1/31/2004 1:44:23 PM
No existing validator has this logic. You will have to either use a
CustomValidator and write both the client and server side logic yourself or
use a third party validator system. For example, my "Professional Validation
And More" (http://www.peterblum.com/vam/home.aspx) includes the
"CountTrueConditionsValidator" which will let you setup 5 "required field
conditions" and count that only one finds text in the textbox.

If you download a free trial version and set it up, the validator will look
something like this:
<vam:CountTrueConditionsValidator id=CTC1 runat=server ErrorMessage="Enter
only one" Minimum=1 Maximum=1 >
<Conditions>
<vam:RequiredTextCondition ControlIDToEvaluate="TextBox1" />
<vam:RequiredTextCondition ControlIDToEvaluate="TextBox2" />
<vam:RequiredTextCondition ControlIDToEvaluate="TextBox3" />
<vam:RequiredTextCondition ControlIDToEvaluate="TextBox4" />
<vam:RequiredTextCondition ControlIDToEvaluate="TextBox5" />
</Conditions>
</vam:CountTrueConditionsValidator>

This will support client-side validation, even on Netscape/Mozilla, Opera 7
and Safari, where Microsoft's validators only work on IE and IE/Mac.

--- Peter Blum
www.PeterBlum.com
Email: PLBlum@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
[quoted text, click to view]

CMA
2/2/2004 3:46:58 PM
hi ray,

pls explain the problem in detail. then only we can help you. if you can
post some code from your page.. it is helpful to resolve ur problem.

regards,
CMA


[quoted text, click to view]

AddThis Social Bookmark Button