Steven Steven - 8 months ago 56
Javascript Question

Disabled fields not picked up by serializeArray

(Question updated to reflect real issue)

I just realized that

is not fetching content from disabled fields.

A set of (street) address fields are populated by selecting an item from a
list. Once this is done, the fields are disabled. I could change this to
read only
, but I want the disabled look and feel without having to change CSS.

Is there a way to have
grab data fro, the disabled fields?


Thanks to Mohammad, I created a small plugin that helps me solve my issue:


var form_data = $('form').serializeAll();

(function ($) {
$.fn.serializeAll = function () {
var data = $(this).serializeArray();

$(':disabled[name]', this).each(function () {
data.push({ name:, value: $(this).val() });

return data;


Try this

var data = $('form').serializeAllArray();

And here is the small plugin that is used

(function ($) {
  $.fn.serializeAllArray = function () {
    var obj = {};

    $('input',this).each(function () { 
        obj[] = $(this).val(); 
    return $.param(obj);

You can also try enabling all your element's just to serialize them and then disable them after serializing.

var myform = $('#form');
var disabled = myform.find(':input:disabled').removeAttr('disabled');
var serialized = myform.serializeArray();