[jQuery] Validate plugin and attribute selector values with [square brackets]
Hi all,
I thought I'd give you all (and Joern also) a heads-up on a problem I've been having.
I use the validate() plugin on forms whose tags have names like 'user[email]'.
The 'rules' option to validate() has no problem with this, but I've now started passing an array of server-side errors to showErrors() which then fails.
The reason is that on line #538 of jquery.validate.js v1.1, the selector resolves to <span style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);">jQuery("[@name=user[email]]")</span>
- I presume that the first closing square bracket is interpreted by jQuery to be closing the selector instead of part of the attribute.
The fix I have discovered is to amend line #538 to put single quotes around the value, like so:
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><span style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);">
element: jQuery("[@name='" + name + "']:first", this.currentForm)[0]</span>
</blockquote>
I'm not sure how advisable that fix is - if anyone can advise on that I'd be very grateful.
As an aside - Joern this is the first time I've used validate, all I'll say is thank you, it's a fantastic plugin very well thought-out.
--rob<br clear="all">
--
Rob Desbois