Opened 9 years ago

Closed 9 years ago

#9570 closed bug (duplicate)

Error on radio and non-radio input sharing a name

Reported by: ardoramor Owned by:
Priority: minor Milestone: none
Component: ui.button Version: 1.9.2
Keywords: Cc:
Blocked by: Blocking:


For the purposes of my development, I have a case where my form has a series of radio buttons and an input type="text" with the same name. The issue comes in when toggling one of the radio buttons. The code uses a function radioGroup only for radio buttons but does not ensure that it only selects radios:

radioGroup = function( radio ) {
   var name =,
      form = radio.form,
      radios = $( [] );
      if ( name ) {
         if ( form ) {
            radios = $( form ).find( "[name='" + name + "']" );
         } else {
            radios = $( "[name='" + name + "']", radio.ownerDocument )
               .filter(function() {
                  return !this.form;
      return radios;

The result is the following uncaught exception: Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'widget'.

The change should be the addition of [type="radio"] as follows:

radios = $( form ).find( "[name='" + name + "'][type='radio']" );
radios = $( "[name='" + name + "'][type='radio']", radio.ownerDocument )

HTML spec does not forbid assigning the same name to inputs. These inputs will be serialized. As such, jQueryUI should handle such case appropriately and only attempt to apply modifications to proper elements.

Change History (1)

comment:1 Changed 9 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #9386.

Note: See TracTickets for help on using tickets.