Hi, i have a page with an input with an onchange event that validates the value entered, it also has button that has an onclick event. when a user puts text in the input and then pushes the button immediately, the onchange is called but the onclick is lost.
@ChikaraOct 10.2007 — #They will both work but onchange works first. Basically this is how things are done.
As you type things into the text box onchange isn't really looking as focus is still on that text box. When you click the button, the text box is blurred and onchange is called. Onclick from the button never gets a chance to fire.
To better understand the problem do this.
Type in some stuff in the text box then click someone else on the page. The onchange event will fire. AFTER you do that click on the button, then the onclick will fire.
I have ran into this problem a few times but alas, I haven't found a clean way around it. If you are trying to validate that text box, just save the validate call for the button. Or you could try using Keydown or Keyup events on that textbox, this will basically validate for each keystroke that is made.
@ChikaraOct 10.2007 — #What exactly are you trying to accomplish with the onchange event? Are you trying to validate input? If it is input, how are you trying to validate it? As in, only number, only letter, only e-mail addresses?
@ran_incauthorOct 10.2007 — #Actually its more complex than that.
The onchange goes to the server where the value is processed and returns to the client(it doesnt really matter what happens in the server, the thing is it has to be onchage or onblur).
To validate if its a number or something like that is easy with onkeyup.