Skip to content

Instantly share code, notes, and snippets.

@ugommirikwe
Created February 7, 2019 21:19
Show Gist options
  • Save ugommirikwe/b96684a41b1ea7eda8d653f4648c9da8 to your computer and use it in GitHub Desktop.
Save ugommirikwe/b96684a41b1ea7eda8d653f4648c9da8 to your computer and use it in GitHub Desktop.
Utility Javascript function to check if a provided value is a valid CSS selector string.
function isValidCssSelector(selector) {
var re = /^[A-Za-z]+[\w\-\:\.]*$/
return re.test(id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment