FFFfaf
Publish Date:
January 24, 2024
// Get the input field and the output field
var inputField = $('#input-title');
var outputField = $('#output-slug');
// When the input field changes, generate the slug
inputField.on('input', function() {
// Get the input value
var inputValue = inputField.val();
// Convert the input value to a slug
var slug = inputValue.toLowerCase()
.replace(/[^\w\s-]/g, '')
.replace(/[\s_-]+/g, '-')
.replace(/^-+|-+$/g, '');
// Set the output value
outputField.val(slug);
});
0 comments: