This almost works. However, when leaving the field \"defaulttext\" appears rather than the original text value. Not sure how to most efficiently echo the variable inside default
You need to remove the ' ' marks around the defaultText variable in your set method (val).
Try something along hte lines of
$(function() {
var defaultText = '';
$('input[type=text]').focus(function() {
defaultText = $(this).val();
$(this).val('');
});
$('input[type=text]').blur(function() {
$(this).val(defaultText); // NB removed the ' ' marks
//echo // What are you trying to echo?
});
});