The generated form includes client-side validation logic using jQuery Validate that provides instant feedback to the user upon submission. If all the field values are valid, then the form is submitted and a customizable callback is issued.
The example below creates a form that asks for the user's name and age. The user's name is a required field, while the age is optional.
See the example in action here
Loading this page in a browser renders a form with two input fields and a submit button.
Both of the fields implement the
required option meaning that if nothing is entered,
an error message will be displayed.
You can do much more with the jsonForms library. You may define a more complex data model that fieldsets, checkboxes, dropdown menus, etc. For more information, check the documentation for jsonForms.
If you're more of a do'er type than a reader, the jsonForms Sandbox is a simple jsonForms powered editor that lets you try out and extend all the examples in the doc.
The jsonForms library requires:
- The jQuery Validate plugin
The jsonForms library may require further libraries, depending on the features you need for the forms you need to render. In particular:
- Bootstrap CSS v3.3.1 or above is more or less needed. You can get away without it but all of the jsonForms forms are rendered with Bootstrap in mind.
All of these libraries are in the repository, although you might want to check their respective Web site for more recent versions.
Note: jsonForms uses
JSON.stringify which are normally supported by modern browsers. If you need to support other browsers, consider adding a JSON library.
The jsonForms library is licensed under the MIT license.
All the libraries that jsonForms depends on are also licensed under the MIT license.