title: Prevent user from pasting line break
body: <p>I'm currently having an issue with a code. In my code, I've got a textarea where the user can enter the title of an article and I would like this article to be only in one row. That's why I wrote a script to prevent users to press the return key. But they could bypass this security, indeed if they copy/past the line break they could enter a line break. So, is there a way to detect line break ? I suppose we can do this with regular expressions and with \n or \n. However I tried this:</p>
  
  <pre><code>var enteredText = $('textarea[name="titleIdea"]').val();
  var match = /\r|\n/.exec(enteredText);
  if (match) {
  
      alert('working');
  }
  </code></pre>
  
  <p>and it doesn't work for an unknown reason. I think the <strong>var enteredText = $('textarea[name="titleIdea"]').val();</strong> doesn't work because when I try to alert() it, it shows nothing. But something strange is that when I do an alert on $('textarea[name="titleIdea"]').val(); and not on the enteredText variable it shows the content.
  Have a great day. (sorry for mistakes, I'm french)</p>