Javascript form generator Javascript form generator jquery jquery

Javascript form generator


If you're looking to generate dynamic forms using jQuery, then I'd recommend taking a look at Alpaca.

Alpaca is an open-source forms library (licensed under Apache 2). It generates forms based on JSON Schema using JavaScript and is pretty flexible so that you can register new control types, layouts, constraints and validation functions.

I think it would handle the scenario you described quite easily.

It has some nice template features (jQuery Templates), rendering engines for jQuery Mobile and a "connector" pattern so that you can read and persist form and layout definitions from a remote data source.

Note: I'm one of the developers at the company behind Alpaca. We open-sourced it because we thought it'd be great for the community. Alpaca is actively developed and we use it for our product (Cloud CMS). Others have used it for other CMS systems as well as projects backed by MongoDB and CouchDB, etc. Thus, it's had a lot of grind put into it.


Try jQuery dForm

Example:

var formdata = {    "action" : "index.html",    "method" : "get",    "elements" :    [        {            "type" : "p",            "html" : "You must login"        },        {            "name" : "username",            "id" : "txt-username",            "caption" : "Username",            "type" : "text",            "placeholder" : "E.g. user@example.com"        },        {            "name" : "password",            "caption" : "Password",            "type" : "password"        },        {            "type" : "submit",            "value" : "Login"        }    ]};$("#myform").buildForm(formdata);

Builds:

enter image description here