if you're using jquery anyway, put this snippet in your <head>, then just add class="swap" and value="default value here" to all your fields
also, you can add css styles for "input.swap.inFocus" to style the boxes that are focused (i make "input.swap" have lightly contrasting text, and "input.swap.inFocus" more readable)
Code:
<script>
$(function() { //onLoad
// "Swap" boxes
swap_val = [];
$(".swap").each(function(i){
swap_val[i] = $(this).val();
$(this).focusin(function(){
if ($(this).val() == swap_val[i]) {
$(this).addClass('inFocus');
$(this).val("");
}
}).focusout(function(){
if ($.trim($(this).val()) == "") {
$(this).removeClass('inFocus');
$(this).val(swap_val[i]);
}
});
});
});
</script>
brief edit, for arguments sake -- how much overhead is jquery, really? when 90% of users have at least 512mb ram, when even microsoft has employed someone solely to make sure IE6 dies and stays dead, when a
10k javascript library can render swfs, even streaming audio/video and "the browser wars" is all about who parses javascript the fastest, you can include a hosted version of jquery from (jquery, google, yahoo, etc, etc) and the files are already cached on *everyone's* browser, is it really that much overhead, to justify the horror that is writing javascript WITHOUT jquery?