Skip to main content
WolfShade
Legend
April 21, 2011
Question

cfinput - onBlur acts like onKeyDown/onKeyPress

  • April 21, 2011
  • 1 reply
  • 2862 views

Hello, everyone.

I have a form with one cfinput type="text" that is using a JavaScript function to blur the input the put focus back on to the input, each time it blurs it calls a JavaScript function that acts like Google's instant search (pulls data from database with each keystroke).

The problem is: in both FF and IE7, if you do NOT touch any keys on the keyboard and simply use the mouse to click outside the input, it acts as if you typed a key on the keyboard and it activates the JS function for the instant search.  This is problematic, as if you just type "bar" into the field and results start showing, the second you go to click on one of the links, it re-does the search for whatever is in the input field and retrieves the same data that is already there.

Is there a way to prevent the JS function from being called whenever one just clicks outside the input field?

Thanks,

^_^

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    April 21, 2011

    Please show code.  Clicking outside the field will trigger an onBlur handler - there's just no way around it.

    Participating Frequently
    April 21, 2011

    BTW - this has nothing to do with cfinput really.  It's all low level HTML/JS.