title: How to prevent a user from just typing spaces in a textarea
body: <p>I have seen many other questions which mostly ask how to prevent spaces from being entered in the whole textarea, but I am wondering how I can check if the textarea just contains spaces?</p>
  
  <p>For example, here is my textarea:</p>
  
  <pre><code>&lt;textarea id='textarea' name='msg' rows='2' maxlength='255' cols='80' placeholder=' Share a thought...'&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>I can easily check if the above is empty by doing:</p>
  
  <pre><code>$post_msg = htmlentities(strip_tags(@$_POST['msg']));
  $post_msg=mysqli_real_escape_string($connect,$post_msg);
  if ($post_msg != "") {
    // do this
  }
  </code></pre>
  
  <p>But, if a user enters just space characters in, then the field is obviously not empty no more, invalidating the above check. How can I check if the user has entered space characters?</p>
  
  <p>A message can start off with space characters, but it cannot only be space chars.</p>