Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10457 closed bug (worksforme)

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

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: None
Component: selector Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


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>


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


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


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






...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[[email protected][baz]]:checked").val(); WORKS

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

Change History (4)

comment:1 Changed 11 years ago by Rick Waldron

Component: unfiledselector
Owner: set to [email protected]
Status: newpending

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

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

comment:2 in reply to:  1 Changed 11 years ago by [email protected]

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 11 years ago by Rick Waldron

Status: newpending

comment:4 Changed 11 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.