macek/jquery-serialize-object

support serialization of elements whose names begin with an "_"

alanning opened this issue · 2 comments

Currently form elements with names that begin with an underscore are ignored.

I already have a PR outstanding so I don't want to mess that up by including another commit but the fix for this is to change this line: https://github.com/macek/jquery-serialize-object/blob/master/jquery.serialize-object.js#L31

 validate: /^[a-z][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,

... to this:

 validate: /^[_a-z][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,

(Note the addition of the underscore in the first bracket group.)

I don't really see the harm in implementing this.

Just so you know though, the patterns are completely configurable to meet your needs.

// allow input names to start with _
FormSerializer.patterns.validate = /^[_a-z][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i

I'll make this update this week along with some other changes.

@alanning taken care of :)