> Use .toLowerCase() .replace(/ /g, '-') .replace(/[^\w-]+/g, ''); and here is an example:
let slug = $('#searchGlobal').val().toLowerCase()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '');
window.location.href = window.location.origin+'/search?q='+slug;