I am using CodeIgniter. I have a form and fields are `Name, Email, Mobile no, Message`.

I am able to submit the data in the database using AJAX. There is no issue with AJAX.

Now What I did, I fill the form and click on submit button twice then I check my database and I found the same records twice because of two clicks. If I click three times on the submit button then I am getting same records three times in the database.

Is there any way to stop this issue. Like one click should work on submit button till the data submitting in the database?

**View**

```
<div class="i_p_aboutTeam_alert" id="popup_verify-1" style="display: none;">
  <div class="profile_content">
    <div class="profile_header clearfix">
         <a href="javascript:void(0);" class="close_popup " onclick="closePopup();"><i class="fas fa-times"></i></a>
      </div>
   <div class="profile_body">
      <div class="form_heading">
      <h2>CONTACT FORM</h2>
   </div>
      <form action="" method="post" name="form" id="form" autocomplete="off">
         <div class="form-group ffl-wrapper">
            <label for="name" class="ffl-label">Name</label>
            <input type="text" name="name" class="form-control" id="name">
         </div>

         <div class="form-group ffl-wrapper">
            <label for="mobileno" class="ffl-label">Mobile Number</label>
            <input type="text" name="mobileno" class="form-control" id="mobileno">
         </div>

         <div class="form-group ffl-wrapper">
            <label for="email" class="ffl-label">Email</label>
            <input type="email" name="email" class="form-control" id="email">

         </div>
           <div class="form-group ffl-wrapper">
            <label for="message" class="ffl-label">Message</label>
            <textarea class="form-control" name="message" id="message"></textarea>
         </div>
         <div class="form-group text-center">
         <input type="submit" name="send" class="i_btn i_btn_bg  i_btn_round w_100p" value="Submit">
      </div>
      </form>
   </div>

  </div>
</div>

```

**AJAX**

```
$("#form").validate({
  rules: {
    name: {
      required: true,
      minlength: 3,
      lettersonly: true
    },
    mobileno: {
      required: true,
      minlength: 10,
      maxlength: 10,
      number: true
    },
    email: {
      required: true,
      email: true
    },
    message: {
      required: true,
      minlength: 10
    }
  },
  submitHandler: function(form) {
    //form.submit();
    $.ajax({
      url: "<?php echo base_url('Home_control/contact');?>",
      type: "POST",
      data: $('#form').serialize(),
      success: function(data) {
        $("#popup_verify-1").hide();
        $("#popup_success-1").show();
      },
    }); // AJAX Get Jquery statment
  }
});

```

**Controller**

```
public function contact() {
  $this -> form_validation -> set_error_delimiters('<div class="error">', '</div>');

  $this -> form_validation -> set_rules('name', 'Name', 'trim|required|min_length[3]');
  $this -> form_validation -> set_rules('mobileno', 'Mobile no', 'trim|required|regex_match[/^[0-9]{10}$/]');
  $this -> form_validation -> set_rules('email', 'email', 'required|valid_email');
  $this -> form_validation -> set_rules('message', 'Message', 'required');

  if ($this -> form_validation -> run() == FALSE) {
    //$this->index();
  } else {
    $form_data = array(
      'name' => $this -> input -> post('name', TRUE),
      'mobileno' => $this -> input -> post('mobileno', TRUE),
      'email' => $this -> input -> post('email', TRUE),
      'message' => $this -> input -> post('message', TRUE)
      );
    $success = $this -> db -> insert('form', $form_data);
    echo json_encode(array("data" => $success)); // return to the ajax
  }

}

```