Opened 11 years ago
Closed 11 years ago
#10457 closed bug (worksforme)
jQuery Incorrectly Parses Form Variable Names Containing # Character and [array]
Reported by: | Owned by: | ||
---|---|---|---|
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[[email protected][baz]]:checked").val(); WORKS
But the # character combined with a sub-array causes jQuery to fail.
Change History (4)
comment:1 follow-up: 2 Changed 11 years ago by
Component: | unfiled → selector |
---|---|
Owner: | set to [email protected]… |
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → new |
---|
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
Status: | new → pending |
---|
comment:4 Changed 11 years ago by
Priority: | undecided → low |
---|---|
Resolution: | → worksforme |
Status: | pending → closed |
Escaping the '#' character solves this: http://jsfiddle.net/GQeGW/
Have you tried escaping the special character and putting the mandatory quotes around the attribute value?