Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$(function() {
// Clone HTML5's placeholder attribute functionality
$('input[placeholder]').each(function() {
// Store the placeholder text and then set the element's value
// TODO: Check to make sure value is empty before setting here
$(this).data('placeholder', $(this).attr('placeholder'));
// Handle the removal/addition of the placeholder text on focus/blur
$(this).focus(function() {
if ($(this).val() == $(this).data('placeholder')) {
}).blur(function() {
if (!$(this).val().match(/\w/)) {
input.placeholder {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.