Created
May 17, 2012 12:46
-
-
Save beshur/2718674 to your computer and use it in GitHub Desktop.
jQuery clear text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by Alex Karpov | |
function prepare_alias(val) { | |
val=val; | |
if (val!="") { | |
var result = val.replace(/ /g, "-"); | |
result = result.replace(/[^a-zA-Z0-9_-]+/g, ''); | |
result = result.replace(/^[-|_]*/g,''); | |
result = result.replace(/[-|_]*$/g,''); | |
result = result.replace(/[-]+/g,'-'); | |
result = result.toLowerCase(); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment