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?