title: checking if user input includes a <script> tag with javascript. Unexpected token {
body: <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
          function XSSPrevent(){
              var usercomments = document.getElementById('usertext').value;
              if(usercomments.contains("&lt;script&gt;"){
                  alert("Failed");
              } else
              alert("Thank you for your comments" + usercomments);
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form&gt;
          &lt;input type="text" id="usertext" maxlength=50/&gt;
          &lt;input type="submit" value="Enter" onclick="XSSPrevent()"/&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>It is my first time to work with both HTML form and javascript. Console</p>
  
  <p>shows an unexpected token { after if loop. What's wrong?<br>
  I know it is not a good idea to use an alert method in this situation but I</p>
  
  <p>just wanna check my function quickly. </p>