CustomControl - Not triggering on an empty field.

E

Eric B

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.
 
E

Eric B

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top