Skip to main content

Bug Tracker

Side navigation

#5667 closed bug (fixed)

Opened December 16, 2009 05:20PM UTC

Closed December 17, 2009 08:06PM UTC

Last modified April 13, 2011 06:08AM UTC

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

Attachments (0)
Change History (6)

Changed December 17, 2009 01:13AM UTC by dmethvin comment:1

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

Changed December 17, 2009 02:07AM UTC by dmethvin comment:2

keywords: serializeserialize html5
priority: majorminor

Changed December 17, 2009 02:44AM UTC by miketaylr comment:3

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

Changed December 17, 2009 03:31AM UTC by dmethvin comment:4

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.

Changed December 17, 2009 08:06PM UTC by john comment:5

resolution: → fixed
status: newclosed

Changed April 13, 2011 06:08AM UTC by anders@janmyr.com comment:6

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);
    });