The following JavaScript function will slugify a given string. For example, passing My New Category would return my-new-category

function slugify(strText){  
    return strText
        .toLowerCase()
        .replace(/ /g,'-')
        .replace(/[^\w-]+/g,'');
}