Custom validator control does not always fire

  • Thread starter Thread starter Dot net work
  • Start date Start date
D

Dot net work

Hello.

If I use an asp.net custom validator control to validate a textbox,
what I find is that if I enter in some text that I have already
entered and validated in a previous session (you know when you start
typing inside a textbox, you see things that have already been typed
before), then when I click off the textbox, the custom validator
client side jscript does not run. I really need the custom jscript
validator code to run everytime, regardless of whether the text in
question has been successfully validated before in a previous session.

Thanks if anyone knows the answer!

-dnw.
 
Validators only fire when the browser invokes the onchange event associated
with the field.

Unfortunately, onchange does not fire in some cases:
- If you edit the field but edit it back to the original.
- If you pick from the AutoComplete dropdown (which I think you are talking
about). Its annoying and personally, I think its a design flaw in IE.

Microsoft has provided a good defense for this: the server side always
validates. You should NEVER assume the client-side validates. Only IE and
IE/Mac browsers support the client-side validation code because its written
in DHTML. The user can disable javascript on those same browsers. So you
must be sure that Page.Validate() is called (it happens automatically on
buttons whose CausesValidation property is true) and you test for
Page.IsValid prior to saving.

--- 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 very much for the info.

Peter Blum said:
Validators only fire when the browser invokes the onchange event associated
with the field.

Unfortunately, onchange does not fire in some cases:
- If you edit the field but edit it back to the original.
- If you pick from the AutoComplete dropdown (which I think you are talking
about). Its annoying and personally, I think its a design flaw in IE.

Microsoft has provided a good defense for this: the server side always
validates. You should NEVER assume the client-side validates. Only IE and
IE/Mac browsers support the client-side validation code because its written
in DHTML. The user can disable javascript on those same browsers. So you
must be sure that Page.Validate() is called (it happens automatically on
buttons whose CausesValidation property is true) and you test for
Page.IsValid prior to saving.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top