relu / contact-form-7-datepicker

Datepicker for Contact Form 7 Wordpress Plugin based on JQueryUI's datepicker (NO LONGER MAINTAINED)
http://wordpress.org/plugins/contact-form-7-datepicker/
28 stars 34 forks source link

hide virtual keyboard #183

Open daduzh opened 7 years ago

daduzh commented 7 years ago

Hello, I am trying to prevent the virtual keyboard from popping up on mobile devices when using the datepicker field in contactform7.

thanks you

rinkaslb commented 6 years ago

Any luck? i'm trying the same thing. Cheers

TomasHurtz commented 5 years ago

I solved the problem for mobiles by adding the following javascript code to only execute if:

To get this to work:

1a) Ensure ID is added to the date field in CF7 (for example: [date* readonly id:myID456..... etc.

1b) If you are using date and time field together, then it looks something like this [datetime* id:myID456 date-format:dd/mm/yy time-format:HH:mm min-date:2 max-date:365 min-hour:9 max-hour:18 step-minute:15 first-day:1]

2a) Add following to your active theme functions file;

function wp223311_hook_javascript() {
    if (is_page(136) ) {   // << id of your page
             if ( wp_is_mobile() ) {  // << only target devices
             ?>
                <script type="text/javascript">
                        jQuery(function() {
                        jQuery( "#myID456" ).datepicker({  }).attr('readonly','readonly').addClass("test");
                        });
                </script>
          <?php
          } // end if wp_is_mobile
    } // end if is_page
} // end function
add_action('wp_head', 'wp223311_hook_javascript');

2b) If you are using date and time field together, then it looks something like this: Same as above except use this instead: jQuery( "#myID456" ).datetimepicker

I also added a test class - so you can easily view source page of code and search for test so you can see the class is added to correct element in form

Good luck!