0

I am trying to validate IDs for HTML 5, jQuery, and CSS

For HTML 5, it's pretty easy: basically just \S+. Yes, you do need one character, but in practice this is never an issue for me.

The problem is with jQuery. I need to weed out at least the apostrophe (') and quote (") characters, plus parenthesis '(' and ')'. When I try to use a jQuery selector like: #he(llo) it throws an Exception.

Right now I am validating my ids negatively in two steps. First, check for matches with '\s', then with the specific characters mentioned above.

I am just wondering if it is possible to do this in 1 regex - especially like "check for \S, plus..." ex. [\S\'\"\(\)]

PM 77-1
  • 12,254
  • 20
  • 64
  • 106
ControlAltDel
  • 32,042
  • 9
  • 48
  • 75

1 Answers1

2

wont something like this work

[^\s'"()]+
kunz
  • 895
  • 1
  • 7
  • 26