restrict space key value to transfer when no other character value is entered
<p>In my Chat application project, I am trying to restrict spaces when the user has just pressed <kbd>Space</kbd> and then <kbd>Enter</kbd>. pressing <kbd>Enter</kbd> will show entered Text into a <code>div</code>. Please see the comments in the code to understand clearly.</p>

<pre><code>#txtmsg --&gt; ID of TextBox field
</code></pre>

<hr>

<pre><code>$('#txtmsg').keypress(function (e)
{
    if (e.which == 13) 
    {
        //Disable default function of Enter key
        e.preventDefault(); 
        //Checks whether the user has entered any value or not
        if ($('#txtmsg').val().length &gt; 0)  
        {
          //if(user has not entered only spaces....)?

           //transfers the entered value in the text field to div
            chat.server.send($('#txtmsg').val());
            $('#txtmsg').val('');
        }
    }
});
</code></pre>
