Bug Tracker

Modify

Ticket #5667 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

serialize / serializeArray ignores HTML 5 input types

Reported by: skyfex Owned by:
Priority: minor Milestone: 1.4
Component: ajax Version: 1.4a1
Keywords: serialize html5 Cc:
Blocking: Blocked by:

Description

When using $(form).serialize, HTML 5 input types are ignored (email, date, datetime, etc.)

It would be much better if serialize worked more like the browsers does, and defaulting to text type if the type is unknown. This makes HTML 5 backwards compatible with most browsers (but not with jQuery in this case).

(Does not seem to be fixed in nightly)

Change History

comment:1 Changed 4 years ago by dmethvin

See also enhancement #4668. Serialize should already work properly on non-HTML5 browsers since elem.type=="text" there.

comment:2 Changed 4 years ago by dmethvin

  • Keywords html5 added
  • Priority changed from major to minor

comment:3 Changed 4 years ago by miketaylr

Looks like you've omitted type=datetime-local from the patch.

comment:4 Changed 4 years ago by dmethvin

It matches datetime in the regexp. I debated whether it might be easier to exclude the types we don't want but settled on this.

comment:5 Changed 4 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed

comment:6 Changed 3 years ago by anders@…

datetime-local does not work with serializeArray()

module('jQuery');
    test('serializeArray should handle datetime and datetime-local', function() {
      $('<form id=form><input type=datetime name=date value=d />' +
        '<input type=datetime-local name=local value=l /></form>').appendTo('body');
      var expected =[{name: 'date', value: 'd'}, {name: 'local', value: 'l'}] 
      deepEqual($('#form').serializeArray(), expected);
    });

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.