How to Fire Validators on TextChange Event

K

Keith H

I have a form with a text box and a button, and I've written my server-side
button click event handler to handle the events of the textbox's textchanged
event as well, and that works fine.

I also have validator controls on the form, and they only work when the
button is actually clicked; but the browser will submit the form to the
server when the user enters some text in the text box and presses the <enter>
key. I want the validators to fire off in both cases.

I've searched around the newsgroups and forums and tried the following based
on something I found that was very close to what I wanted (though there was
no follow-up post to indicate whether it worked or not). This isn't working
for me:

Dim strOnChange As String = "if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " & Page.GetPostBackClientEvent(txtSlideNo, "")
txtSlideNo.Attributes.Add("onchange", "this.form.txtSlideNo.click();")

....even though I can view source and see the exact same javascript for the
onchange attribute of my text box that the onclick attribute of my button
has.

Can this be done in a relatively simple way? What am I missing?
 

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,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top