Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda