Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Prevent script tags from executing on page load with form get

I have a search page which has a form.

<form method="get" action="/search">
  <input type="text" id="search" name="search" />
</form>

When I am loading the url with the search querystring, I am getting an alert, I would like to avoid this.

http://localhost/search?search=<script>alert(document.cookie)</script>

I tried this but it isn't working,

$( document ).ready(function() {
var search_value = $('#search').val();
if(search_value !== '')
  {
   search_value = search_value.replace(/(<([^>]+)>)/ig,"");
   $('#search').val(search_value);
  }
});

I would like to process the string before the loading, but I am unable to, any suggestions on how to fix this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!