Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript sanitize input slug

	// https://stackoverflow.com/a/1054862/485063
	jq('.input.slug, .slug, input .slug').unbind().bind('keyup paste', function(){
		var low=	jq(this).val().toLowerCase()
			.replace(/ /g,'-')
			.replace(/\_/g,'-')
			.replace(/[^w-]+/g,'')
			.replace(/--+/g,'-');
		
		jq(this).val(low);
	});
 
PREVIOUS NEXT
Tagged: #javascript #sanitize #input #slug
ADD COMMENT
Topic
Name
9+4 =