Bug Tracker

Opened 8 years ago

Closed 8 years ago

#10457 closed bug (worksforme)

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

Reported by: carlroett@… Owned by: carlroett@…
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> &nbsp;

<label>

<input type="radio" value="profile" name='foo#bar[baz]' />Profile </label> &nbsp;

<label>

<input type="radio" value="tab" name='foo#bar[baz]' />Tab </label> &nbsp;

</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.

Change History (4)

comment:1 Changed 8 years ago by Rick Waldron

Component: unfiledselector
Owner: set to carlroett@…
Status: newpending

Have you tried putting the mandatory quotes around the attribute value?

Version 0, edited 8 years ago by Rick Waldron (next)

comment:2 in reply to:  1 Changed 8 years ago by carlroett@…

Status: pendingnew

Replying to 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.

comment:3 Changed 8 years ago by Rick Waldron

Status: newpending

comment:4 Changed 8 years ago by addyosmani

Priority: undecidedlow
Resolution: worksforme
Status: pendingclosed

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

Note: See TracTickets for help on using tickets.