Skip to content

Instantly share code, notes, and snippets.

@cwardzala
Created July 5, 2012 16:31
Show Gist options
  • Save cwardzala/3054671 to your computer and use it in GitHub Desktop.
Save cwardzala/3054671 to your computer and use it in GitHub Desktop.
Modernizr.changeinputtype test
/**
* Use Modernizr to test if changing input.type is allowed in x browser.
* Based on supportsChangingTypeAttribute from http://lea.verou.me/2009/06/on-password-masking-and-usability/
*/
Modernizr.addTest('changeinputtype', function () {
var input = document.createElement('input');
try {
input.type = 'password';
input.type = 'text';
} catch (e) {
return false;
}
return input.type == 'text';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment