Prevent paste input into date picker field [RESOLVED]

Hi, I’m looking for a jQuery snippet to prevent pasting a date into the date field.
I have added restricted dates to the calendar and disabled the possibility to edit the date, but it is still possible to copy paste a date directly into the date field.
Hope someone can help.

Try this:

jQuery(document).ready(function($){
    jQuery('input.datepicker').on("cut copy paste",function(e) {
        e.preventDefault();
    });
});

If it’s specific to one field, you could place it in an HTML field in that form between <script type="text/javascript"></script>, and change the selector from input.datepicker to the ID of the specific input, eg. #input_5_9

Hope this helps!
:slight_smile:

1 Like

Hi Scott,
Thanks for your suggestions. It’s working perfectly.

1 Like

Glad to help! You can mark this question as solved by clicking the solution button to the left of the like button on my original answer to accept it as a solution. :slight_smile:

1 Like