KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am creating a JavaScript function that will take a user inputted value and and create a CSS class name out of it. The following expression can be used to detect whether the end result follows valid css rules -?[_a-zA-Z]+[_a-zA-Z0-9-]* but I need to find a way to use it to remove all invalid characters. I was thinking of something like: var newClass = userInput.replace(EVERYTHING BUT /[_a-zA-Z0-9-]/, "");
Tags (comma-separated)
Save Edits
Cancel