Replace text in input

by Johan Preynat

HTML

<input type="text" id="mybox" name="phrase" value="Enter text here..." size="24"/>

JavaScript

var defaultValue = "Enter text here...",
    newValue = "New text here...";

$('#mybox').focusin(function() {
    $(this).val(newValue);
});

$('#mybox').focusout(function() {
    $(this).val(defaultValue);
});