Skip to content

Instantly share code, notes, and snippets.

@06b
Created September 4, 2012 02:21
Show Gist options
  • Save 06b/3615821 to your computer and use it in GitHub Desktop.
Save 06b/3615821 to your computer and use it in GitHub Desktop.
Some mobile browsers autocapitalize inputs, This applies the autocapitalize='off' option to all inputs with a specific class, so it won't autocapitalize them.
<script>
//Description: Some mobile browsers autocapitalize inputs, This applies the autocapitalize='off' option to all inputs with a specific class, so it won't autocapitalize them.
//Author: Andrew Nesbitt
$(document).ready(function(){
// disable autocapitalize on .url, .email fields
unautocapitalize('url');
unautocapitalize('email');
});
function unautocapitalize(cssClass){
var elems = document.getElementsByClassName(cssClass);
for (var j = 0; j < elems.length; j++){
elems[j].setAttribute('autocapitalize', 'off');
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment