3

Here's some code:

<form>
<input type="text" name="Title" pattern="[a-zA-Z0-9`\~\!\@\#\$\%\^\&\*\(\)\-\\\\=\+\{\}\[\]\']{2,40}" required>
<input type="submit">
</form>

I would like to add quotes to the allowed in the regex expression, however \" does not work and &quot does not work, either...

JVE999
  • 3,327
  • 10
  • 54
  • 89
  • 3
    With that much included stuff, you could almost allow `.`. Why not disallow characters instead? – Brad Jul 25 '13 at 02:46
  • I didn't think of that. How would I just disallow `.` and a couple others? – JVE999 Jul 25 '13 at 02:51
  • 1
    Disallow literal `.` --> `[^\.]` – Daniel Haley Jul 25 '13 at 02:51
  • 3
    try this answer http://stackoverflow.com/a/12620317/1378879 with " = \x22 OR \u0022 with ' = \x27 OR \u0027 – StupidDev Jul 25 '13 at 02:51
  • Awesome, so I'd just replace quotes with `\x22`. @DanielHaley Awesome, too. Now I'll have to figure out which one to use. I can't remember all of the original reasons I chose to specifically allow, so I might stick with replacing it with `\x22`, since it's so simple and less modifying. – JVE999 Jul 25 '13 at 02:55
  • 2
    @StupidDev - You should add your comment as an answer so it can be accepted (and upvoted). – Daniel Haley Jul 25 '13 at 02:59

1 Answers1

0

So I can just replace the quotes with \x22. Now I'll have to figure out which one to use (I can instead disallow instead of allow, or use \x22 in place of the quotes). I can't remember all of the original reasons I chose to specifically allow, so I might stick with replacing it with \x22, since it's so simple and less modifying.

JVE999
  • 3,327
  • 10
  • 54
  • 89