Bug Tracker

Modify

Ticket #10457 (closed bug: worksforme)

Opened 20 months ago

Last modified 20 months ago

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:
Blocking: Blocked by:

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

comment:1 follow-up: ↓ 2 Changed 20 months ago by rwaldron

  • Owner set to carlroett@…
  • Status changed from new to pending
  • Component changed from unfiled to selector

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

Last edited 20 months ago by rwaldron (previous) (diff)

comment:2 in reply to: ↑ 1 Changed 20 months ago by carlroett@…

  • Status changed from pending to 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 20 months ago by rwaldron

  • Status changed from new to pending

comment:4 Changed 20 months ago by addyosmani

  • Priority changed from undecided to low
  • Status changed from pending to closed
  • Resolution set to worksforme

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.