Validators and client side script

M

Mike Surcouf

Hi

I have some regex validators on my page set to dynamic and like the way they
appear after you tab out of a field and also when you try to postback the
form.
All OK so far

When I register for the client side event of a textbox using ...

textBox.Attributes.Add("onKeyUp","javascriptfunction");

eg onKeyUp or onKeyDown the above validators stop working for the case when
you leave the text box (postback still works).
I was thinking it is probably because I have overidden the event the
validators use. I had a good look at the source of the page but couldnt see
the client side events for the validators.

Is am thinking there must be a way to have the validators working for
controls with their own clientside events otherwise no one could write a
control which works with the ASP.NET validators.

Many Thanks

Mike
 
H

Hans Kesting

Hi
I have some regex validators on my page set to dynamic and like the way they
appear after you tab out of a field and also when you try to postback the
form.
All OK so far

When I register for the client side event of a textbox using ...

textBox.Attributes.Add("onKeyUp","javascriptfunction");

eg onKeyUp or onKeyDown the above validators stop working for the case when
you leave the text box (postback still works).
I was thinking it is probably because I have overidden the event the
validators use. I had a good look at the source of the page but couldnt see
the client side events for the validators.

Is am thinking there must be a way to have the validators working for
controls with their own clientside events otherwise no one could write a
control which works with the ASP.NET validators.

Many Thanks

Mike

Try and add a ";" after your "javascriptfunction", as a separator
between your statement and the .net autogenerated one.
(at least for linkbuttons, this works)

Hans Kesting
 
M

Mike Surcouf

Cheers Stan

For anyone else I found that this out

Writing a javascript function that hooks onKeyDown I change the value of
the textbox.
This has the effect of breaking the lost focus validation.
You can cause the validator to fire by calling
ValidatorOnChange(event);

in your javascript.

Mike
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top