Simple Add remove input fields dynamically using jquery with Bootstrap

By Hardik Savani | August 19, 2016 | Category : PHP Javascript Bootstrap jQuery

In this tutorial, I am going to show you how to add remove input fields dynamically in your form using jquery. In this simple example, i give you to add multiple input fields with remove button that way you can remove field if you don't require. In this example i use bootstrap also because layout become pretty good.

In this example, Simply i added two click event of jquery as listed bellow:

1.add-more Class: On ".add-more" class that way we can write jquery append code.

2.remove Class: On ".remove" class that way we can remove input field.

I also added "copy" class div, that will be append after "after-add-more" class that way you can also modify easily on "copy" class like you want to change text or icon etc. It is pretty simple example and you can easily customize this example.

You have to create two file one for generate script code of add more input fields, and second file for getting value of dynamic field value.

So, let's create both files, after finish this example you will find bellow output. you can check on demo for dynamic add more input fields.



<html lang="en">


<title>Bootstrap Jquery Add More Field Example</title>

<script src=""></script>

<link rel="stylesheet" href="">



<div class="container">

<div class="panel panel-default">

<div class="panel-heading">Bootstrap Jquery Add More Field Example</div>

<div class="panel-body">

<form action="action.php" >

<div class="input-group control-group after-add-more">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-success add-more" type="button"><i class="glyphicon glyphicon-plus"></i> Add</button>




<!-- Copy Fields -->

<div class="copy hide">

<div class="control-group input-group" style="margin-top:10px">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-danger remove" type="button"><i class="glyphicon glyphicon-remove"></i> Remove</button>







<script type="text/javascript">

$(document).ready(function() {


var html = $(".copy").html();











In this PHP file you can get value of multiple input fields this way:





Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: