Hi @selolascases,
Glad to know that you’re enjoying the plugin. Regarding the “paste” function, there isn’t any out-of-the-box feature, however, based on your form I suppose you are looking to prevent it for input fields and textarea for every form?
If yes, you can try this snippet:
<?php
add_action('wp_footer', function() {
?>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Select all input fields and textareas with Forminator classes
var formElements = document.querySelectorAll('.forminator-input, .forminator-textarea');
// Loop
formElements.forEach(function(element) {
element.addEventListener('paste', function(e) {
e.preventDefault();
alert('Paste operation is not allowed.');
});
});
});
</script>
<?php
});
The following line in the above code targets the input field and the textarea:
var formElements = document.querySelectorAll('.forminator-input, .forminator-textarea');
If you only want to disable paste for the textarea then updating the following line as below should be good:
var formElements = document.querySelectorAll('.forminator-textarea');
You can implement the above code using mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Best Regards,
Nithin
Hi @selolascases,
Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to open a new thread if you have new queries.
Kind Regards
Nithin
Hello,
thank you for your answer. I am sorry I did not reply earlier my “webrelated” activity had slowed down a lot and starts to regain a bit vitality now only.
I did as you proposed (at least I think) but up to now, it does not seem to work = paste is still allowed in text aeras. What did I do wrong, please ? https://ibb.co/1Kv7B7T
I cannot find the mu-plugins folder among my plugins in my admin interface. I only found it browsing the file manager of my admin interface and the above screenshot comes from there.
Have a nice day
Hello again,
I found the solution myself : I forgot to save the file I created according to your snippet as a .php file ! It was a simple .txt file. Now that I changed the snippet extension from .txt to .php, it works just fine !
So sorry for opening this post again because of my distraction.
Have a nice day !