1

I have an asp.net program in which I place a marker on a google map when the address in a textbox is changed. This Javascript is triggered by the onchange event. However I have noticed that if the user does not 'tab' out of the box before clicking submit, the event does not fire. Is there a way I can fix this?

3
  • when you won to fire ? on every user click ? Commented Jan 30, 2012 at 0:29
  • i want it to fire when the text is changed, it works correctly in most cases, the problem is when the user changes the text and immediately clicks the submit button without clicking out of the box first...it seems to skip firing the event. Commented Jan 30, 2012 at 0:37
  • Perhaps try onblur , occasionally I've had success with one when the other fails. Commented Jan 30, 2012 at 0:41

1 Answer 1

1

I think what you are trying to achieve is impossible. the onchange event, happens only when you lose focus on the element. You could use onkeypress, onkeydown or onkeyup to get that change quicker. The problem here is that the value of the textbox is going to be changed by the click of an external element and therefore, you cannot bind it directly to the textbox.

If you know exactly what the clickable elements would be, you could add a click event to each one of them, pointing to a function that would test the textbox current value against the latest known value and if they were different, do whatever you want to do. But i don't think that's the case...

following your comment, you should add a submit event to the form, that would compare the current state of the textbox before submitting the form...

Sign up to request clarification or add additional context in comments.

1 Comment

Actually.......I do know the clickable elemets, really just the submit button, so I added a call to another function that check to make sure a field was set, if not it called the onchange fnc from there. Thanks ( :

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.