title: jQuery: Check if special characters exists in string
body: <p>I know this question is asked more often here on Stack, but I can't seem to get a straight answer out of the questions already posted.</p>
  
  <p>I need to check if all special characters (except -) are in a string, if so, then give the user an alert.</p>
  
  <p>What I have so far is this:</p>
  
  <pre><code>if($('#Search').val().indexOf('@') == -1 || $('#Search').val().indexOf('#') == -1 || $('#Search').val().indexOf('$') == -1 || $('#Search').val().indexOf('%') == -1 || $('#Search').val().indexOf('^') == -1 || $('#Search').val().indexOf('&amp;') == -1 || $('#Search').val().indexOf('*') == -1 || $('#Search').val().indexOf('(') == -1 || $('#Search').val().indexOf(')') == -1 || $('#Search').val().indexOf('_') == -1 || $('#Search').val().indexOf('\'') == -1 || $('#Search').val().indexOf('\"') == -1 || $('#Search').val().indexOf('\\') == -1 || $('#Search').val().indexOf('|') == -1 || $('#Search').val().indexOf('?') == -1 || $('#Search').val().indexOf('/') == -1 || $('#Search').val().indexOf(':') == -1 || $('#Search').val().indexOf(';') == -1 || $('#Search').val().indexOf('!') == -1 || $('#Search').val().indexOf('~') == -1 || $('#Search').val().indexOf('`') == -1 || $('#Search').val().indexOf(',') == -1 || $('#Search').val().indexOf('.') == -1 || $('#Search').val().indexOf('&lt;') == -1 || $('#Search').val().indexOf('&gt;') == -1 || $('#Search').val().indexOf('{') == -1 || $('#Search').val().indexOf('}') == -1 || $('#Search').val().indexOf('[') == -1 || $('#Search').val().indexOf(']') == -1 || $('#Search').val().indexOf('+') == -1 || $('#Search').val().indexOf('=') == -1)
  {
     // Code that needs to execute when none of the above is in the string
  }
  else
  {
    alert('Your search string contains illegal characters.');
  }
  </code></pre>
  
  <p>But this doesn't seem to work... Can anyone help me on this matter?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Guido</p>