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 7742381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:15:43+00:00 2026-06-01T09:15:43+00:00

I am new to PHP Codeigniter framework. I am designing a page in which

  • 0

I am new to PHP Codeigniter framework. I am designing a page in which I am using a link. On clicking the link it is calling a jquery function, which submits form through jquery. I have used codeigniter form validation methods for server side validation and for the timebeing I have disabled the client side validation.

The problem is that in this process when the form is submitted through jquery, the codeigniter form validation method is not working.

But if I am using a submit button to submit the form then the codeigniter form validation method works perfectly.

Please advise me what to do if I need to submit the form through jquery and use the codeigniter form validation method.

Please find the code below:

Login Form:

<?php echo validation_errors(); ?>
<form name="login-form" id="login-form" method="post" action="<?php echo base_url();?>index.php/login/login_form" >
    <H2>Login</H2>
    <div id="login-box-name">
        Email:
    </div>
    <div id="login-box-field">
        <input name="user-name" id="user-name" class="form-login" title="Please Enter Correct User Name" value="" size="30" maxlength="2048" />
    </div>
    <div id="login-box-name">
        Password:
    </div>
    <div id="login-box-field">
        <input name="password" id="password" type="password" class="form-login" title="Please Enter Correct Password" value="" size="30" maxlength="2048" />
    </div>
    <br />
    <span class="login-box-options">
        <input type="checkbox" name="1" value="1" title="Want this computer to remember you!!"> Remember Me <a href="#" id="login-div-change">Forgot password?</a>
    </span>
    <br />
    <br />
    <a href="" id="login-submit">
        <img src="<?php echo base_url();?>assets/images/login-btn.png" width="110" height="40" style="margin-left:90px;" />
    </a>
    <input type="submit" name="submit" id="submit" value="Submit" />
</form>

jquery function to submit the form on clicking the “link”:


    $("#login-submit").click(function()
    {
    $('#login-form').submit();
    return false;
    });

Controller function:


    public function login_form()
    {

        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $data['title'] = 'Log In';

        $data['errorMessage'] = '';
        $this->form_validation->set_rules('user-name', 'Email', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == FALSE)
        {
        $this->load->view('templates/header', $data);
        $this->load->view('login', $data);
        $this->load->view('templates/footer');
        }

        else
        {
        $this->load->view('templates/header', $data);
        $this->load->view('templates/menu');
        $this->load->view('index', $data);
        $this->load->view('templates/footer');
        }

    }

Here if I click on the “Submit button of the form, then the codeigniter validation works for user-name and password fields. But if I click the link with id=”login-submit”, then it calls the jquery function and the form get submitted. But the codeigniter validation does not work for user-name and password fields this time.

I need to submit the form through the link and the codeigniter validation function should work for this.

Thanks in Advance…..

  • 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-01T09:15:45+00:00Added an answer on June 1, 2026 at 9:15 am

    Use .preventDefault() instead of just returning false on the anchor click event.

    This has happened to me before and it seems to me that there is a conflict somewhere using .submit() inside a click event and returning false to stop the anchor’s default behavior.

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

Sidebar

Related Questions

I'm using the CodeIgniter PHP framework. I have a simple form that has an
I'm new to PHP and I'm confused seeing some examples calling a function with
I am using PHP and the codeigniter framework for a project I am working
I am using codeigniter php framework. I am suffering from the problem that all
I am new to PHP codeigniter, how to get checkbox values using php Codeigniter
I am trying to get started with the PHP MVC framework, CodeIgniter. I am
I'm using the Codeigniter framework and am in the process of creating a registration
I'm using git to manage an extended CodeIgniter Framework. It's a clone of the
I'm trying using ElasticSearch with Codeigniter framework. What i did is just install ElasticSearch
I have a PHP web application built with CodeIgniter MVC framework. I wish to

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.