Giter Club home page Giter Club logo

Comments (3)

macek avatar macek commented on August 14, 2024

Thanks for the detailed paste. It makes it way easier to help with this kind of issue.

The fix is relatively simple. You have full control over the regexp patterns that this plugin is using internally.

A simple tweak to FormSerializer.patterns.validate can allow numbers as the initial character

// this is the original
FormSerializer.patterns.validate = /^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i;

Override the pattern using $.extend

// allow alphanumeric first character
$.extend(FormSerializer.patterns, {
  validate: /^[a-z0-9_-]+(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,
});

Set this snippet to initialize on page load. Any subsequent calls to $.fn.serializeObject or $.fn.serializeJSON will utilize the new patterns.

Let me know if this works for you.

from jquery-serialize-object.

macek avatar macek commented on August 14, 2024

@malles, just one more thing to mention here.

The 3.x version of this plugin will be serializing according to the W3C draft spec for JSON serialization of forms.

Such modifications will not be required to get your desired output once that's ready.

from jquery-serialize-object.

malles avatar malles commented on August 14, 2024

Thanks @macek! It works like a charm.
Awaiting the new version, this plugin helps me out bigtime.

from jquery-serialize-object.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.