Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created December 27, 2012 18:29
Show Gist options
  • Save wpscholar/4390673 to your computer and use it in GitHub Desktop.
Save wpscholar/4390673 to your computer and use it in GitHub Desktop.
Prevent the display of the pop-up keyboard on mobile devices
/**
* Using this snippet of code, just add the 'mobile-no-keyboard' class to your input or textarea
* to prevent the keyboard display on most mobile devices. You can just add the 'readonly' attribute,
* but there may be reasons you don't want to on a desktop/laptop machine.
*/
jQuery(document).ready(function($) {
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
$('input.mobile-no-keyboard, textarea.mobile-no-keyboard').attr( 'readonly', 'readonly' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment