/ Published in: jQuery

Takes one field and converts the string to a URL-friendly slug in a second field
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function convertToSlug(Text) { return Text.toLowerCase().replace(/[^\w ]+/g,'').replace(/ +/g,'-'); } // Usage: $("#Name").keyup(function(){ $("#Slug").val(convertToSlug($(this).val())); });
URL: http://stackoverflow.com/questions/1053902/how-to-convert-a-title-to-a-url-slug-in-jquery
Comments
