Ver Mensaje Individual
  #8 (permalink)  
Antiguo 26/04/2014, 08:34
Avatar de Landa11
Landa11
 
Fecha de Ingreso: febrero-2014
Ubicación: En algún lugar de mi oficina
Mensajes: 148
Antigüedad: 11 años
Puntos: 1
Respuesta: Deshabilitar pegado especial con teclas con JS

mmmmm sigo teniendo problemas por que si me deja pegar... estoy utilizando varios scripts pero algunos son para deshabilitar el botón del ratón o para validar sólo números al momento de escribir

Código Javascript:
Ver original
  1. <!--Deshabilitar tecla enter para envio de formulario erroneo
  2.     Se agrega el onkeydown="return intro(event) a cada input"-->
  3. <script language="javascript">
  4. function intro(e)
  5. {
  6.     tecla = (document.all) ? e.keyCode : e.which;
  7.     if (tecla==13)
  8.     {
  9.         return false;
  10.     }
  11. }
  12. </script>

Código Javascript:
Ver original
  1. <!--Script para validar campo solo numerico-->
  2. <script language="javascript">
  3. function soloLetras(e) {
  4.     key = e.keyCode || e.which;
  5.     tecla = String.fromCharCode(key).toLowerCase();
  6.     letras = "0123456789";
  7.     especiales = [8, 17, 18, 19, 37, 39, 45, 46, ];
  8.  
  9.     tecla_especial = false
  10.     for(var i in especiales) {
  11.         if(key == especiales[i]) {
  12.             tecla_especial = true;
  13.             break;
  14.         }
  15.     }
  16.  
  17.     if(letras.indexOf(tecla) == -1 && !tecla_especial)
  18.         return false;
  19. }
  20.  
  21. function limpia() {
  22.     var val = document.getElementById("cantidad").value;
  23.     var tam = val.length;
  24.     for(i = 0; i < tam; i++) {
  25.         if(!isNaN(val[i]))
  26.             document.getElementById("cantidad").value = '';
  27.     }
  28. }
  29. </script>

Código Javascript:
Ver original
  1. <!--Deshabilitar boton derecho de rat�n-->
  2.  
  3. <script language="javascript">
  4. document.oncontextmenu = function()
  5. {
  6.     return false
  7. }
  8. </script>
  9.  
  10. <body>
  11. <script language="javascript">
  12. var input = document.getElementsByTagName("input")[0];
  13.  
  14. input.addEventListener("paste", function(e){
  15.     e.preventDefault();
  16. }, false);
  17. </script>
__________________
Ayudando a la gente con nuestros códigos para poder tener el conocimiento adecuado y ser libres!