Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. block copy/paste for textbox in firefox

block copy/paste for textbox in firefox

Scheduled Pinned Locked Moved ASP.NET
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashok techxygen
    wrote on last edited by
    #1

    hi , how can i block copy/paste option (or) right click for a text box in firefox both in keyboard and right click option in mouse... its working in IE...

    Ashok

    M E 2 Replies Last reply
    0
    • A ashok techxygen

      hi , how can i block copy/paste option (or) right click for a text box in firefox both in keyboard and right click option in mouse... its working in IE...

      Ashok

      M Offline
      M Offline
      MoustafaS
      wrote on last edited by
      #2

      onmousedown="return false;" onkeydown="return false;"


      About : Islam
      About : Me

      A 1 Reply Last reply
      0
      • M MoustafaS

        onmousedown="return false;" onkeydown="return false;"


        About : Islam
        About : Me

        A Offline
        A Offline
        ashok techxygen
        wrote on last edited by
        #3

        hi, ur code is working in IE but not in firefox... I ve tried this already... Any idea

        Ashok

        1 Reply Last reply
        0
        • A ashok techxygen

          hi , how can i block copy/paste option (or) right click for a text box in firefox both in keyboard and right click option in mouse... its working in IE...

          Ashok

          E Offline
          E Offline
          eyeseetee
          wrote on last edited by
          #4

          use this javascript: function noCopyKey(e) { var forbiddenKeys = new Array('c','x'); var keyCode = (e.keyCode) ? e.keyCode : e.which; var isCtrl; if(window.event) isCtrl = e.ctrlKey else isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false; if(isCtrl) { for(i = 0; i < forbiddenKeys.length; i++) { if(forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) { alert('This action has been restricted, for more information contact MJM'); return false; } } } return true; }

          A 1 Reply Last reply
          0
          • E eyeseetee

            use this javascript: function noCopyKey(e) { var forbiddenKeys = new Array('c','x'); var keyCode = (e.keyCode) ? e.keyCode : e.which; var isCtrl; if(window.event) isCtrl = e.ctrlKey else isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false; if(isCtrl) { for(i = 0; i < forbiddenKeys.length; i++) { if(forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) { alert('This action has been restricted, for more information contact MJM'); return false; } } } return true; }

            A Offline
            A Offline
            ashok techxygen
            wrote on last edited by
            #5

            hi, thanks 4 ur reply... this code is working to block on keyboard to copy/paste... But i cannot block right click and paste from mouse button...

            Ashok

            E 1 Reply Last reply
            0
            • A ashok techxygen

              hi, thanks 4 ur reply... this code is working to block on keyboard to copy/paste... But i cannot block right click and paste from mouse button...

              Ashok

              E Offline
              E Offline
              eyeseetee
              wrote on last edited by
              #6

              try this: if ( document.layers ) { window.captureEvents(Event.MOUSEDOWN); window.onmousedown = function(e) { if ( e.target == document ) return false; } } else { document.onmousedown = function() { return false; } }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups