Skip to content

Instantly share code, notes, and snippets.

@gcollazo
Created January 12, 2010 15:47
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 gcollazo/275293 to your computer and use it in GitHub Desktop.
Save gcollazo/275293 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var origValue = 'Nombre';
var field = $('#smartField');
field.val(origValue);
field.css("color","grey");
field.focus(function(){
if(field.val() === origValue){
field.css("color","#E3E3E3");
}
});
field.blur(function(){
if(field.val() === ''){
field.val(origValue);
field.css("color","grey");
}
if(field.val() === origValue){
field.css("color","grey");
}
});
field.keypress(function(){
if(field.val() === origValue){
field.val('');
field.css("color","black");
}
});
});
</script>
</head>
<body>
<form action="fields_submit" method="get" accept-charset="utf-8">
<input type="text" name="texto" id="smartField" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment