Modifying a customValidator error message from the client function?

Discussion in 'ASP .Net' started by Damon, Mar 17, 2006.

  1. Damon

    Damon Guest

    I'd like to be able to modify the error message of an ASP.NET 2.0
    customValidator on the fly, depending on what part of the validation
    failed. Now, the client validation function takes two parameters, the
    second of which points to the value to be validated (args.Value). I
    can't seem to locate what exactly the first parameter points to, and
    trying to debug the Javascript in Visual Studio 2005 and figure this
    out is problematic at best.

    Is it possible to reference the ErrorMessage field of the
    customValidator, or will I *shudder* need to roll my own custom field
    validation?

    Damon
    Damon, Mar 17, 2006
    #1
    1. Advertising

  2. Damon

    Damon Guest

    Damon wrote:
    > I'd like to be able to modify the error message of an ASP.NET 2.0
    > customValidator on the fly, depending on what part of the validation
    > failed. Now, the client validation function takes two parameters, the
    > second of which points to the value to be validated (args.Value). I
    > can't seem to locate what exactly the first parameter points to, and
    > trying to debug the Javascript in Visual Studio 2005 and figure this
    > out is problematic at best.
    >
    > Is it possible to reference the ErrorMessage field of the
    > customValidator, or will I *shudder* need to roll my own custom field
    > validation?


    *bump*

    Still having trouble with this.

    Here's my javascript validation code for one of the fields. This isn't
    the final form of the validation, though. I want to check more stuff
    but I need to get this question answered first.

    function validateEditClient(val, args) {
    args.IsValid = (args.Value.length > 0) && (args.Value.length <=
    100);
    if (!(args.IsValid)) {

    document.getElementById('ctl00_ContentPlaceHolder1_DetailsView1_txtEditClient').style.backgroundColor='red'
    } else {

    document.getElementById('ctl00_ContentPlaceHolder1_DetailsView1_txtEditClient').style.backgroundColor='white'
    };
    }

    I know what to do with the "args" parameter. But where, oh where is
    there any documentation on what's being passed in the "val" parameter??

    I want to be able to use it to programmatically reference the text
    that's contained in the ErrorMessage property (or alternatively the
    Text property) of the customValidator object. How can I do this?

    Damon
    Damon, Mar 18, 2006
    #2
    1. Advertising

  3. Damon

    blue875

    Joined:
    Jun 23, 2009
    Messages:
    1
    Three years later, but here it is anyway:
    val.setAttribute("errormessage", "You have a dynamic error message.");
    blue875, Jun 23, 2009
    #3
    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. Jon Davis
    Replies:
    1
    Views:
    6,852
    Ken Cox [Microsoft MVP]
    Jan 21, 2004
  2. John Bonds

    CustomValidator client-side scripting

    John Bonds, Aug 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    4,226
    John Bonds
    Aug 23, 2004
  3. COHENMARVIN

    CustomValidator doesn't give error message

    COHENMARVIN, Aug 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,446
    Peter Blum
    Aug 5, 2005
  4. avp
    Replies:
    1
    Views:
    21,644
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Dec 16, 2005
  5. Talisker
    Replies:
    0
    Views:
    242
    Talisker
    Jun 9, 2006
Loading...

Share This Page