Dynamically Create HTML Form Fields - jQuery Dynamic Forms

File Size: 7.24 KB
Views Total: 32774
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Dynamically Create HTML Form Fields - jQuery Dynamic Forms

Yet another dynamic form creation plugin which allows to dynamically add and remove form fields (form groups) for those who want to enter more information in an HTML form.

How to use it:

1. Insert the latest version of jQuery JavaScript library and the JavaScript file dynamic-form.js into the page.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" 
<script src="js/dynamic-form.js"></script>

2. Insert add/remove buttons to the form groups you want to duplicate.

<div id="dynamic_form">
  <div class="form-control">
    <input type="text" name="p_name" id="p_name" placeholder="Enter Product Name">
  <div class="form-control">
    <input type="text" name="quantity" id="quantity" placeholder="Enter Product Quantity">
  <div class="form-control">
    <textarea name="remarks" placeholder="Enter Remarks" id="remarks"></textarea>
  <div class="button-group">
    <a href="javascript:void(0)" class="btn btn-primary" id="plus">Add More</a>
    <a href="javascript:void(0)" class="btn btn-danger" id="minus">Remove</a>

3. Attach the form duplication functionality to the form group. Possible parameters:

  • selectedTarget: target form controls
  • plusSelector: CSS selector of Add button
  • minusSelector: CSS selector of Remove button
  • options: options object
// dynamicForm(selectedTarget, plusSelector, minusSelector, options)
var dynamic_form =  $("#dynamic_form").dynamicForm("#dynamic_form","#plus", "#minus", {
    // options here

4. Full plugin options.

var dynamic_form =  $("#dynamic_form").dynamicForm("#dynamic_form","#plus", "#minus", {

    // the maximum number of form fields
    limit: 10,

    // prefix

    // normalize all fields
    // ideal for server side dulication
    normalizeFullForm: false,

    // color effects
    createColor: '',
    removeColor: '',
    duration: 3000,

    // JSON data which will prefill the form
    data: {}


This awesome jQuery plugin is developed by Hemant411. For more Advanced Usages, please check the demo page or visit the official website.