How To jQuery JavaScript conditional statement (beginner)
<p>Apologies if this is an overly simple question, but my searches are getting me nowhere.</p>

<p>I have a jQuery function which produces an error on some of my pages which do not contain the <code>#message</code> input:</p>

<pre><code>Error: jQuery("#message").val() is undefined
Line: 56
</code></pre>

<p>And my jQuery function:</p>

<pre><code>function updateCountdown()
{
    var $left = 255 - jQuery( '#message' ).val().length;

    jQuery( '#countdown' ).text( $left + ' Characters Remaining' );
}

$( document ).ready( function()
{
    updateCountdown();

    $( '#message' ).change( updateCountdown );
    $( '#message' ).keyup( updateCountdown );
});
</code></pre>

<p>So my question is, how do I use a conditional to remove the error message from pages without the <code>#message</code> input? I believe my problem is a basic lack of knowledge of how JavaScript works.</p>
