1<script>
2$(document).ready(function() {
3 var max_fields = 10;
4 var wrapper = $(".container1");
5 var add_button = $(".add_form_field");
6
7 var x = 1;
8 $(add_button).click(function(e) {
9 e.preventDefault();
10 if (x < max_fields) {
11 x++;
12 $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="delete">Delete</a></div>'); //add input box
13 } else {
14 alert('You Reached the limits')
15 }
16 });
17
18 $(wrapper).on("click", ".delete", function(e) {
19 e.preventDefault();
20 $(this).parent('div').remove();
21 x--;
22 })
23});
24 </script>
25<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
26<div class="container1">
27 <button class="add_form_field">Add New Field
28 <span style="font-size:16px; font-weight:bold;">+ </span>
29 </button>
30 <div><input type="text" name="mytext[]"></div>
31</div>