• Resolved selolascases

    (@selolascases)


    Hello,

    Firts of all I want to write how grateful I feel for this forminator plugin, it meets my needs very well in almost all of its aspects. I would just want to disable the “paste” function in some parts of the forms I created and did not find how to do it, I come here to learn it if it is possible, if you please.

    Thank you for reading me and have a nice day !

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    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

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    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

    Thread Starter selolascases

    (@selolascases)

    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

    Thread Starter selolascases

    (@selolascases)

    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 !

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Disable “paste” function in forminator Forms ?’ is closed to new replies.