Return to Snippet

Revision: 27159
at May 25, 2010 21:06 by jmiller


Initial Code
function convertToSlug(Text) {
	return Text.toLowerCase().replace(/[^\w ]+/g,'').replace(/ +/g,'-');
}


// Usage:
$("#Name").keyup(function(){
	$("#Slug").val(convertToSlug($(this).val()));
});

Initial URL
http://stackoverflow.com/questions/1053902/how-to-convert-a-title-to-a-url-slug-in-jquery

Initial Description
Takes one field and converts the string to a URL-friendly slug in a second field

Initial Title
Convert to slug

Initial Tags
convert

Initial Language
jQuery