Skip to content

Instantly share code, notes, and snippets.

@fabiancarlos
Created June 14, 2012 22:31
Show Gist options
  • Save fabiancarlos/2933420 to your computer and use it in GitHub Desktop.
Save fabiancarlos/2933420 to your computer and use it in GitHub Desktop.
Pré mensagens para inputs (jQuery)
function preMessage(id_input, message_input){
"use strict";
id_input.val(message_input);
id_input.focusin(function(){
checkInputFormsNull($(this), message_input);
});
id_input.focusout(function(){
checkInputFormsNull($(this), message_input);
});
function checkInputFormsNull (input, value) {
if (input.val() === '' ) {
input.val(value);
}else if(input.val() === value){
input.val("");
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment