Custom validator control does not always fire

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.
 
P

Peter Blum

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
 
D

Dot net work

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
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top