Block Contact Form Spam By Disabling Paste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable copy paste into text area fields to prevent spammers from blowing up forms | |
jQuery(document).on('YourEventTypicallyDocumentReady', function() { | |
// disable keyboard paste | |
jQuery('YourFormFieldSelector').bind("cut copy paste", function(e) { | |
e.preventDefault(); | |
}); | |
// disable context menu to prevent right click pasting | |
jQuery('YourFormFieldSelector').bind("contextmenu", function(e) { | |
e.preventDefault(); | |
}); | |
}); | |
/* Below are some semi complete examples, use with caution */ | |
/* Catch All On Ready */ | |
// disable copy paste into text area fields to prevent spammers from blowing up forms | |
jQuery(document).on('ready', function() { | |
// disable keyboard paste | |
jQuery('form textarea').bind("cut copy paste", function(e) { | |
e.preventDefault(); | |
}); | |
// disable context menu to prevent right click pasting | |
jQuery('form textarea').bind("contextmenu", function(e) { | |
e.preventDefault(); | |
}); | |
}); | |
/* End Catch All OnReady */ | |
/* Ninja Forms */ | |
// disable copy paste into text area fields to prevent spammers from blowing up forms | |
jQuery(document).on('nfFormReady', function() { | |
// disable keyboard paste | |
jQuery('.nf-form-wrap textarea').bind("cut copy paste", function(e) { | |
e.preventDefault(); | |
}); | |
// disable context menu to prevent right click pasting | |
jQuery('.nf-form-wrap textarea').bind("contextmenu", function(e) { | |
e.preventDefault(); | |
}); | |
}); | |
/* End Ninja Forms Example */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment