Validation Groups is not designed for this. It lets a submit control
determine which validators to fire.
You need a way to disable/enable a validator based on the value of something
else on the page. There is no built in feature to do that in ASP.NET on the
validators. You have several options:
1. Post back to the server side to handle validation. (No client-side
validation.) I describe a technique in this article about common issues with
validators:
http://aspalliance.com/699.
2. Write javascript code that is called when the value of the textbox
changes, to enable the validator on the client-side. The validation scripts
include this function:
function ValidatorEnable(val, enable)
val - use document.getElementById('ClientID of the validator')
enable - true or false
3. Use my replacement to the ASP.NET Validators, Professional Validation And
More (
http://www.peterblum.com/vam/home.aspx). Its 25 validators have this
capability built in. Use the Enabler property to describe the rule that
enables the validator. For more:
http://www.peterblum.com/VAM/DemoEnabler.aspx
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"ibiza" <la******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,
I have a small question concerning asp.net 2.0 validation groups. I
have this (simplified) situation :
Name Value
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|
So I have 6 textboxes, that goes in pair by row. I'd like the user to
choose whatever boxes he wants to fill, meaning that he can save either
one, two or three name-value pairs. The problem is, a name cannot be
saved without a value and vice-versa. I thought asp.net 2.0 would solve
my validation problems with its new "groups" feature, but I can't
manage how to tell him that "if the user fills one box, the other
besides it must also be filled". I tried many different ways of doing
this, right now I ended with 6 requiredfieldvalidator and textboxes
aside set with the same ValidationGroup, for a total of 3 different
ValidationGroup-s. Can't I programmatically set which ValidationGroup I
want to use just before Page.Validate or anything like this that would
do the job?.....
thanks for your feedback,
ibiza