/ Published in: JavaScript
A lovely little one liner that strips out all non alphanumeric chars first, then replaces the spaces with hyphens, then converts all to lowercase :D
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('#permalink').val($(this).val().replace(/\s/g, '-').replace(/[^\w/-]/g, '').toLowerCase());