Skip to content

Instantly share code, notes, and snippets.

@alaasalama
Created February 16, 2016 11:38
Show Gist options
  • Save alaasalama/c5274a6c24771d518fed to your computer and use it in GitHub Desktop.
Save alaasalama/c5274a6c24771d518fed to your computer and use it in GitHub Desktop.
<script>
jQuery( document ).ready(function() {
jQuery('input[name=log]').val('');
jQuery('input[name=pwd]').val('');
jQuery('#log')
.on('blur', function(){
var jQuerythis = jQuery(this);
if(jQuerythis.val() == 'Username'){
jQuerythis.val('');
}
})
jQuery('#pwd')
.on('blur', function(){
var jQuerythis = jQuery(this);
if(jQuerythis.val() == 'Password'){
jQuerythis.val('');
}
})
});
</script>
@alaasalama
Copy link
Author

This JavaScript snippet to hide the value of text inputs based on their names, then emptying the onBlur and onFocus values based on the inputs IDs (these default values were "username/Password")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment