Skip to content

Instantly share code, notes, and snippets.

@ambienttraffic
Created January 25, 2011 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambienttraffic/795133 to your computer and use it in GitHub Desktop.
Save ambienttraffic/795133 to your computer and use it in GitHub Desktop.
jquery function to clear the default value from a text field, and replace it with the default field if it's still empty.
$(document).ready(function(){
$('#emailfield').click(function() {
if ($(this).val() == 'Your Email') {
$(this).data('original', $(this).val()).val('');
}
});
$('#emailfield').blur(function() {
if ($(this).val() == '') {
$(this).val($(this).data('original'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment