SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2010
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Some puzzling javascript triggering an onchange handler

    Hello,

    I have something puzzling with an input field at the page:

    http://www.thalasoft.com/elearning/e.../subscription/

    If typing the word MillÚsime in the first question input field, then the answer is correct.

    But, let's say your computer keyboard does not offer the Ú letter, you use the Ú letter by clicking on it in the "Mini clavier".

    The problem then, is that the onchange handler is triggered. I would like to add a letter in the input field but not trigger the onchange handler.

    Any one sees a solution ?

    Thanks

    Stephane

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onchange is triggered whenever you blur the input field, which you do when you click your other field. Simplest to remove the onchange event, though you could give it a timeout and cancel it when the other field is focused.

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2010
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if my explanation was clear enough for you to understand it. I click in the input field, I then type in a few letters, like Mill, and then I click on the displayed Ú letter above. It should add this Ú letter in the input field so as to have MillÚ, and it should not do any blur nor change, because I wish to finish typing in my word, so as to have in the input field the word MillÚsime, and then I can click to the next field, triggering the onchange and see the ajax correction.

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2010
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @mrhoo

    I now understand what is going on:

    The onchange event will be triggered before the onclick handler is performed :
    1░) user is writing in the input field
    2░) user clicks on the mini keyboard
    3░) input field lose focus
    4░) input field's onchange event is triggered
    5░) mini keyboard has focus
    6░) mini keyboard's onclick handler is performed

    Which shows me you clearly understood the problem from the start.

    Following up on your two suggestions, if I remove the onchange event handler, then how would I handle changes if the on screen keyboard is not used ?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •