javascript sanitize input slug 1

javascript sanitize input slug

	jq('.input.slug, .slug, input .slug').unbind().bind('keyup paste', function(){
		var low=	jq(this).val().toLowerCase()
			.replace(/ /g,'-')

Here is what the above code is Doing:
1. When the user types in the input field, the value is converted to lowercase.
2. All spaces are replaced with hyphens.
3. All underscores are replaced with hyphens.
4. All non-word characters are removed.
5. All multiple hyphens are replaced with a single hyphen.

Similar Posts