How to merge these various statements into more elegant code
<pre><code>$('.search-input').focus(function () {
    $(this).val('');
});
$('.search-input').blur(function () {
    if ($(this).val() == '') {
        $(this).val('enter the place');
    }

});

$('#edit-name').keyup(function () {
    if ($(this).val() != '') {
        $('.username .error-message').remove();
    } else {
        $('#edit-name').after('&lt;span style="color:red;" class="error-message" &gt;enter the name！&lt;/span&gt;');
    }
});

$('#edit-name').blur(function () {
    if ($(this).val() == '') {
        $('.username .error-message').remove();
        $('#edit-name').after('&lt;span style="color:red;" class="error-message" &gt;enter the name！&lt;/span&gt;');
    }

});

$('#edit-pass').keyup(function () {
    if ($(this).val() != '') {
        $('.password .error-message').remove();
    } else {
        $('#edit-pass').after('&lt;span style="color:red;" class="error-message"&gt; enter the password！&lt;/span&gt;');
    }
});

$('#edit-pass').blur(function () {
    if ($(this).val() == '') {
        $('.password .error-message').remove();
        $('#edit-pass').after('&lt;span style="color:red;" class="error-message" &gt;enter the password！&lt;/span&gt;');
    }

});
</code></pre>

<p>Is there a way to merge or beauty  the code?thank you.</p>
