Skip to main content

Bug Tracker

Side navigation

#10457 closed bug (worksforme)

Opened October 08, 2011 01:56PM UTC

Closed October 09, 2011 08:34AM UTC

jQuery Incorrectly Parses Form Variable Names Containing # Character and [array]

Reported by: carlroett@gmail.com Owned by: carlroett@gmail.com
Priority: low Milestone: None
Component: selector Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

Given the following general structure, embedded inside a web page with a form, etc. Testing in FireFox 7.0.1 with jQuery v1.6.1

=

<table class="form-table targetOne">

<tr>

<th valign="top">Location</th>

<td>

<label>

<input type="radio" value="page" name='foo#bar[baz]' checked='checked' />Page </label>  

<label>

<input type="radio" value="profile"

name='foo#bar[baz]' />Profile

</label>  

<label>

<input type="radio" value="tab"

name='foo#bar[baz]' />Tab </label>  

</td>

</tr>

</table>

=

jQuery("input[name=foo#bar[baz]]:checked").val();

...returns "undefined", when it should return the value of the currently selected radio button.

Changing the "name" in the form to match...

jQuery("input[name=foo#bar]:checked").val(); WORKS

jQuery("input[name=foo[baz]]:checked").val(); WORKS

jQuery("input[name=foo@bar[baz]]:checked").val(); WORKS

But the # character combined with a sub-array causes jQuery to fail.

Attachments (0)
Change History (4)

Changed October 08, 2011 04:49PM UTC by rwaldron comment:1

_comment0: Have you tried putting the mandatory quotes around the attribute value?1318092599446588
component: unfiledselector
owner: → carlroett@gmail.com
status: newpending

Have you tried escaping the special character and putting the mandatory quotes around the attribute value?

Changed October 08, 2011 04:53PM UTC by carlroett@gmail.com comment:2

status: pendingnew

Replying to [comment:1 rwaldron]:

Have you tried escaping the special character and putting the mandatory quotes around the attribute value?

Please post an example of what you're referring to.

Changed October 08, 2011 05:26PM UTC by rwaldron comment:3

Changed October 09, 2011 08:34AM UTC by addyosmani comment:4

priority: undecidedlow
resolution: → worksforme
status: pendingclosed

Escaping the '#' character solves this: http://jsfiddle.net/GQeGW/