El evento onPaste

30/Ene/2013 255

Eventualmente podrías tener un <textarea> donde permitas al usuario pegar lo que tiene guardado en su clipboard. Quizás deseas impedir al usuario pegar contenido en un campo de formulario, por ejemplo, en uno de password. Para ambos casos existe un evento denominado onPaste.

Impedir pegar:

onPaste="return false;"

Manipular el valor de lo pegado:

onPaste="var e=this; setTimeout(function(){alert(e.value);}, 0);

Debes usar un setTimeout debido a que el evento onPaste responde antes de que el contenido es pegado en el elemento, por lo que no tiene tiempo suficiente para manejarlo. setTimeout 0 es automáticamente recalculado a 4ms ya que es el valor mínimo en HTML5.

Ver ejemplo

Comentarios

  1. golden goose [#]

    I in addition to my friends appeared to be examining the good guidelines on your site and so at once I had a terrible suspicion I never expressed respect to the website owner for them. Those women had been totally happy to read them and now have simply been making the most of those things. Appreciate your truly being so considerate and then for picking variety of really good useful guides most people are really needing to understand about. My very own sincere apologies for not expressing gratitude to sooner.

  2. hermes [#]

    Thanks for each of your effort on this blog. My aunt really loves conducting investigations and it is obvious why. My partner and i notice all regarding the compelling medium you make important steps by means of this web site and foster response from others on this concept then my simple princess is really starting to learn so much. Take pleasure in the remaining portion of the new year. Your carrying out a tremendous job.

  3. yeezy shoes [#]

    Thanks a lot for providing individuals with an exceptionally remarkable opportunity to read in detail from this blog. It really is very ideal and also full of amusement for me personally and my office acquaintances to search your web site a minimum of three times a week to read the latest stuff you will have. And definitely, we are always impressed concerning the gorgeous tips served by you. Selected 4 areas on this page are completely the most beneficial I’ve ever had.

  4. stromectol [#]

    General Low-down Here this by-product
    https://ivermectstromect.com ivermectin for sale humans
    https://ivermectinst.com ivermectin 12 mg
    https://ivermectinsts.com ivermectin tablets
    https://ivermectinsts.com ivermectin for sale humans
    https://ivermectinst.com ivermectin 12 mg

  5. GustavoVet [#]

    professional paper writers
    [url=»https://essayghostwriter.com/?»]do my homework app[/url]

CSSLab