I have the following script which works great however I think this can be simplify, right? also, I'd like it to trigger only once.
Example, user inputs "My Title". Script executes and user sees "my-title" in slug field. If user replaces title value by "My Crazy Title", I'd like the slug to remain "my-title". How?
$('#article_title').change(function() {
str = $('#article_title').val();
formatted = str.replace(/\s+/g, '-').toLowerCase();
$('#article_slug').val(formatted);
});
See code example http://jsfiddle.net/TSrYu/