Dynamic Form Creation Deletion - Download Dynamic Form Field Creation & Deletion Plugin - add-input-area

Download Dynamic Form Field Creation & Deletion Plugin – add-input-area

Posted on

This time I will share jQuery Plugin and tutorial about Dynamic Form Field Creation & Deletion Plugin – add-input-area, hope it will help you in programming stack.

Dynamic Form Creation Deletion - Download Dynamic Form Field Creation & Deletion Plugin - add-input-area
File Size: 334 KB
Views Total: 1751
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

add-input-area is a simple-to-implement yet highly-customizable jQuery plugin used to duplicate/add/delete any number of form fields within the document.

Basic usage:

1. Download and place the minified version of the jQuery add-input-area plugin after jQuery JavaScript library.

2         integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
3         crossorigin="anonymous"></script>
4 <script src="dist/jquery.add-input-area.min.js"></script>

2. Insert your form field into a list (or any other container element such as table) and create the Add/Delete buttons as follows:

1 <ol id="list">
2   <li class="list_var">
3     <input type="text" name="list_0" id="list_0">
4     <button type="button" class="list_del">Delete Button</button>
5   </li>
6 </ol>
7 <input type="button" value="Add Button" class="list_add">

3. Just call the function on the list and the plugin will take care of the rest.

1 $(function() {
2   $('#list').addInputArea();
3 });

4. Customize the naming rules of the name & id attributes.

1 <textarea
2   id="posts_0_mail"
3   data-id-format="posts_%d_mail"
4   name="data[posts][mail][0]"
5   data-name-format="data[posts][mail][%d]"
6 ></textarea>

5. You’re also allowed to add/remove multiple form fields at a once.

1 <ol id="list">
2   <li class="list_var">
3     <input type="text" name="list-name_0">
4     <input type="text" name="list-mail_0">
5     <button type="button" class="list_del">Delete Button</button>
6   </li>
7 </ol>
8 <input type="button" value="Add Button" class="list_add">

6. Possible customization options which can be passed to addInputArea() function on init.

01 $('#list').addInputArea({
02  
03   // CSS selector of add button
04   btn_add: '.(id)_del',
05  
06   // CSS selector of delete button
07   btn_del: '.(id)_del'
08  
09   // CSS selector of wrapper element
10   area_var: '.(id)_var'
11  
12   // CSS selector of delete button's wrapper
13   area_del: '.(id)_var'
14  
15   // a callback function which will be fired after adding
16   after_add: null,
17  
18   // whether to clone events
19   clone_event: true,
20  
21   // maximum number of form fields to duplicate
22   maximum: 0,
23  
24   // css selector to avoid duplicating
25   dont_clone:  null,
26  
27   // validat before adding
28   vali<a href="https://www.jqueryscript.net/time-clock/">date</a>: null
29    
30 });

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

source : jquery.net