Custom Validator

  • Thread starter Thread starter brian
  • Start date Start date
B

brian

I am trying to implement a custom validator Client Side.
I have the server side code working fine. I place the
below script below the body tag outside the <form> tag.

My if statement actually contains about 5 conditions.
The bigest thing is I want to dynamically configure the
error message. If I take out the object.ErrorMessage
= "TEST" then the control will pick up on the invalid
entry but I have no message displayed.

<Script language="vbscript" runat="server">
Sub ValidText(sender as object, arg as
servervalidateeventargs)
IF Not isnumeric(arg.value) then
arg.isvalid = false
object.ErrorMessage = "Test"
end if
end sub

Does anyone know how to dynamcially display an error
message.

Thanks
 
Are you getting an error at runtime that 'object does not contain the
property ErrorMessage' (or something like that?)
You did not typecast 'object' to CustomValidator.

CType(object, CustomValidator).ErrorMessage = "Test"

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Thanks for your reply. Yes that is the error I get. Would I do the
type cast in the vbscript? CType(object, CustomValidator).ErrorMessage
= "Test"
 
Back
Top