Capturing paste from right-click context menu

J

james

Hi all,

I've got an input field and a button on a form.

The button should be disabled unless there is something in the input
field.

I've got this working fine using the keyup event for the input field.

However, I am having problems when the user pastes into the input
field using the right-click context menu and then pasting from there,
in that I can't see where I can catch the associated event.

The onchange event is no use, as this is only triggered when the input
field loses focus.

Our customers are using IE6 and IE7.

Does anyone know how I can do this?

Thanks,

James
 
R

RobG

Hi all,

I've got an input field and a button on a form.

The button should be disabled unless there is something in the input
field.

It's not a good idea to be a control freak with a web application.
Consider leaving the button enabled and check the field when the user
clicks on it - presumably it's a submit button in a form so use the
submit event. That will make future maintenance and changes much
easier to manage as well.

I've got this working fine using the keyup event for the input field.

However, I am having problems when the user pastes into the input
field using the right-click context menu and then pasting from there,
in that I can't see where I can catch the associated event.

There is no standard event for pasting, however IE has onpaste and
Firefox has oninput. Onpaste is a bit unreliable, sometimes if fires
before the paste has actually occurred.

If the user has form auto-complete enabled, that may also give you
issues. Just leave the button enabled and validate using submit.
 
J

james

(e-mail address removed) said the following on 2/7/2008 4:19 AM:













onpaste.

But, use the onclick of the button to see if the value is '' and if it
is, then put a note on the page to the user that the field can't be
empty and they need to fill it out.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -

Hi Randy,
Thanks - onpaste is one option, but only in IE. Good point to just
validate on the onclick.

James
 
J

james

It's not a good idea to be a control freak with a web application.
Consider leaving the button enabled and check the field when the user
clicks on it - presumably it's a submit button in a form so use the
submit event.  That will make future maintenance and changes much
easier to manage as well.



There is no standard event for pasting, however IE has onpaste and
Firefox has oninput.  Onpaste is a bit unreliable, sometimes if fires
before the paste has actually occurred.

If the user has form auto-complete enabled, that may also give you
issues.  Just leave the button enabled and validate using submit.

Hi Rob,
Thanks - agree it's probably better to validate on the button click.

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top