Skip to content

Instantly share code, notes, and snippets.

@MaraScott
Created February 22, 2013 03:16
Show Gist options
  • Select an option

  • Save MaraScott/5010473 to your computer and use it in GitHub Desktop.

Select an option

Save MaraScott/5010473 to your computer and use it in GitHub Desktop.
Name : checkEmptyInput(idemail ,defaultvalue) - Language : javascript - type : function - platform : jQuery - tag :
function checkEmptyInput(idInput ,defaultvalue) {
"use strict";
jQuery("#"+idInput).focus(function(){
if (defaultvalue === jQuery("#"+idInput).val()) {
jQuery(this).val('');
} // END IF
});
// FOCUSOUT INPUT
jQuery("#"+idInput).blur(function(){
if (jQuery("#"+idInput).val() === '') {
jQuery("#"+idInput).val(defaultvalue);
} // END IF
});
} // END FUNCTION
jQuery(document).ready(function(){
"use strict";
var defaultvalue = "Votre e-mail"; var idInput = 'customerEmail';
checkEmptyInput (idInput ,defaultvalue);
jQuery("#"+idInput).focus().blur();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment