0

I've an input field I need to validate before sending the form.

So I bind a keyup event on this field, it send a XmlHttpRequest, and then I show the result on my ihm. It works fine.

But modern browsers provide some other way to add information into an input fields:

  • It remembers last value and provides them as a dropdown

enter image description here

  • It is also possible to paste from clipboard

I tried various event to detect them, but no one's (keyup exepted of course) were triggered.

$('#theForm').on('keyup', '.url', checkUrl);
$('#theForm').on('changes', '.url', checkUrl);
$('#theForm').on('click', '.url', checkUrl);

Is it possible to detect these events?

My target browser is Firefox 17.

Fractaliste
  • 5,777
  • 11
  • 42
  • 86

1 Answers1

1

You can detect that event by using the input event:

$('#theForm').on('input', '.url', checkUrl);

fiddle to test: http://jsfiddle.net/t8exjuq2/

enter image description here

Clicking that:

enter image description here

(submit the input of the fiddle once to get a tooltip)

Edit :: Tested in firefox 22.0 and chrome

Also, please note that the change event will listen to almost everything but this.

Final edit ::

About the paste, you can detect that event by using.... paste :

$('#theForm').on('paste', '.url', checkUrl);

http://jsfiddle.net/490gz5vy/

briosheje
  • 7,356
  • 2
  • 32
  • 54