Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9287007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:33:46+00:00 2026-06-18T19:33:46+00:00

I am sending dynamically created form fields to CodeIgniter via ajax. <div class=form-element> <input

  • 0

I am sending dynamically created form fields to CodeIgniter via ajax.

    <div class="form-element">
        <input type="radio" id="delete-radio[1]" name="delete-radio[1]" value="1">
    </div>

    <div class="form-element">
        <label for="member_id[1]">Membership ID</label>
        <input type="text" id="member_id[1]" name="member_id[]" autocomplete="off" value="<?php echo set_value('member_id[1]'); ?>"/>
        <?php echo form_error('member_id[1]', '<div class="error">', '</div>'); ?>
    </div>

    <div class="form-element">
        <label for="member_name[1]">Name</label>
        <input type="text" id="member_name[1]" name="member_name[]" autocomplete="off" value="<?php echo set_value('member_name[1]'); ?>"/>
        <?php echo form_error('member_name[1]', '<div class="error">', '</div>'); ?>
    </div>

    <div class="form-element">
        <label for="member_address[1]">Address</label>
        <input type="text" id="member_address[1]" name="member_address[]" autocomplete="off" value="<?php echo set_value('member_address[1]'); ?>"/>
        <?php echo form_error('member_address[1]', '<div class="error">', '</div>'); ?>
    </div>

I use the following to send them to their controller:

$('#submit').click(function() {
    var form_data = $('#ajax-form').serialize();
    alert(form_data);

    $.ajax({
        url: "<?php echo site_url('ajax_ci/ajax_check'); ?>",
        type: 'POST',
        async : false,
        data: form_data,
        success: function(msg) {
            $('#form-name').append(msg);
        }
    });
    return false;
});

Here is the controller:

if ($this->input->is_ajax_request()) {
    $this->form_validation->set_rules('member_id[]', 'member ID', 'trim|required|xss_clean');
    $this->form_validation->set_rules('member_name[]', 'member name', 'trim|required|xss_clean');
    $this->form_validation->set_rules('member_address[]', 'member password', 'trim|required|xss_clean');

    if($this->form_validation->run() == FALSE) {
        echo validation_errors();       
    } else {
        // connect to database
    }

} else {
    echo "Work on it! Don't give up!";
}

The screenshot below is currently what happens.
enter image description here
But I want these errors to appear in their respective individual form_errors
enter image description here

Is this possible in my current setup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:33:47+00:00Added an answer on June 18, 2026 at 7:33 pm

    In the validation errors that you return from the server, you will need to include information about which field failed. Probably an array of (fieldname=>errormsg). Your ajax response handler can then find the correct field and append the message to the DOM accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to insert extra form fields. function addFormField() { $(#divTxt).append(<div
I'm sending a page event: page.sendEvent('click', 650, 430); This clicks a link that dynamically
I sending ajax request from a jQuery file like below, which expects response in
I am sending data to webserver in the Querystrings by creating URL dynamically. When
So I have this form and the client is inquiring about sending an .ics
I'm try to use MPI_Scatter, sending rows of matrix(that are dynamically allocated), but it
I'm trying to fetch posts dynamically using AJAX and JQuery by checking if the
I have a form with a table where new rows can be added/deleted dynamically
I am trying to add dynamically a user control I created to an aspx
I'm doing a select box with a list of items(dynamically created from an XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.