Modifying a customValidator error message from the client function?

D

Damon

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
 
D

Damon

Damon said:
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
 
Joined
Jun 23, 2009
Messages
1
Reaction score
0
Three years later, but here it is anyway:
val.setAttribute("errormessage", "You have a dynamic error message.");
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top