CustomControl - Not triggering on an empty field.

Discussion in 'ASP .Net Building Controls' started by Eric B, Sep 2, 2003.

  1. Eric B

    Eric B Guest

    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.
    Eric B, Sep 2, 2003
    #1
    1. Advertising

  2. Eric B

    Eric B Guest

    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.
    >
    >
    >
    >
    >
    Eric B, Sep 3, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric B
    Replies:
    1
    Views:
    1,886
    Eric B
    Sep 3, 2003
  2. ButlerDJIAM
    Replies:
    0
    Views:
    556
    ButlerDJIAM
    Nov 9, 2006
  3. Dave

    Literal content is not allowed within a CustomControl?

    Dave, Aug 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    652
  4. Eric B

    CustomControl - Not triggering on an empty field.

    Eric B, Sep 2, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    136
    Eric B
    Sep 3, 2003
  5. Sound
    Replies:
    2
    Views:
    439
    Randy Webb
    Sep 28, 2006
Loading...

Share This Page