Fractaliste
Fractaliste

Reputation: 5957

How to detect input's changes from unexpected mouse actions?

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:

enter image description here

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.

Upvotes: 0

Views: 55

Answers (1)

briosheje
briosheje

Reputation: 7446

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/

Upvotes: 1

Related Questions