I found a post on google newsgroups by Bruce Barker.
You da man Bruce! :)
According to Bruce you can change WebUIValidation.js and modify
CustomValidatorEvaluateIsValid.
I did the following.
function CustomValidatorEvaluateIsValid(val)
{
var value = "";
if (typeof(val.controltovalidate) == "string")
{
value = ValidatorGetValue(val.controltovalidate);
// if (ValidatorTrim(value).length == 0)
// return true;
}
var args = { Value:value, IsValid:true };
if (typeof(val.clientvalidationfunction) == "string")
{
eval(val.clientvalidationfunction + "(val, args) ;");
}
return args.IsValid;
}
Works fine for me.
Eric B <no> wrote:
Hi,
I've made a serverside component that automatically adds a validator.
Currently i have both a REQUIRED validator and a CUSTOM validator in it.
The customValidator has a javascript function that checks the value and if the
value is bad it makes the control RED.
(All done client side)
My problem now is that i also want to do that with fields that are required.
So i have two options:
Extend the requiredvalidator somehow so it will also change the color of
controls.
or
Somehow get the CustomValidator to trigger when fields are empty.
I do not understand why it does not trigger on empty fields.. what if someone
wants to make a customcontrol that does several checks, including a required
check?
Anyway.. what i prefer is to get rid of the RequiredValidator and keep using
the CustomValidator.
Does anyone have any tips how to do either of these?
Kind regards, Eric.