Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > CustomControl - Not triggering on an empty field.

Reply
Thread Tools

CustomControl - Not triggering on an empty field.

 
 
Eric B
Guest
Posts: n/a
 
      09-02-2003

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.





 
Reply With Quote
 
 
 
 
Eric B
Guest
Posts: n/a
 
      09-03-2003
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.
>
>
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Literal content is not allowed within a CustomControl? Dave ASP .Net Building Controls 2 08-02-2006 07:45 PM
writing a customControl philipp ASP .Net 2 05-18-2005 03:40 AM
A HtmlControl as Customcontrol Property KMILO ASP .Net 0 04-22-2005 09:17 PM
CustomControl - Not triggering on an empty field. Eric B ASP .Net Web Controls 1 09-03-2003 09:24 AM
CustomControl - Not triggering on an empty field. Eric B ASP .Net 1 09-03-2003 09:24 AM



Advertisments