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

  • Home
  • SEARCH
  • 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 9006377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:23:43+00:00 2026-06-16T01:23:43+00:00

I have a form that I submit with jQuery ajax and have it being

  • 0

I have a form that I submit with jQuery ajax and have it being sent to a controller function called submit to validate and do any other tasks I need to with the form data. I’m trying to find out why my form validation library isn’t showing an error when the username doesn’t contain only lowercase letters and numbers.

$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|strtolower');

POST Value after form submission:

username    TestingUSER

EDIT:

As far as I know it gets to the php server side properly.

PHP:

public function submit()
{
    $output_status = 'Notice';
    $output_title = 'Not Processed';
    $output_message = 'The request was unprocessed!';

    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|strtolower');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
    $this->form_validation->set_rules('remember', 'Remember Me', 'trim|xss_clean|integer');

    if ($this->form_validation->run() == TRUE)
    {

    }
    else
    {
        $output_status = 'Error';
        $output_title = 'Form Not Validated';
        $output_message = validation_errors();
    }

    echo json_encode(array('output_status' => $output_status, 'output_title' => $output_title, 'output_message' => $output_message));
}

EDIT 2:

Based off of Sheikh answer. I am getting a response back that says “Unable to access an error message corresponding to your field name.” It does say Form Not Validated for the title so the message isn’t working.

public function check_username($str)
{
    if (preg_match('#[0-9]#', $str) && preg_match('#[a-z]#', $str)) 
    {
        return TRUE;
    }
    $this->form_validation->set_message('username', 'This is not have an accepted value!');
    return FALSE;
}

EDIT 3:

What I’m wanting to do is have it report back that there there are validation errors but not the specific errors in the pnotify response. However I do want it to display the specific errors under the form elements.

jQuery Code:

http://pastebin.com/1KehMJkh

Login Form:

http://pastebin.com/EfpBfbfN

  • 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-16T01:23:44+00:00Added an answer on June 16, 2026 at 1:23 am

    I think you can use a callback function in your controller

    public function check_username($str)
    {
        if (preg_match('#[a-z0-9]#', $str)) {
            return TRUE;
        }
        $this->form_validation->set_message('check_username', 'This is not have an accepted value!');
        return FALSE;
    }
    

    Validation rules for username

    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|callback_check_username');
    

    You may like this too.

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

Sidebar

Related Questions

I have a form that is being serialized by JQuery and posted via .ajax()
I have a form on a webpage that I submit using the jquery form
I have an Ajax form that updates a div when submitted with a submit
I have a form validation method that's called on submit. It executes a get
I have a remote form that is populated by jQuery with an AJAX request.
I have a form that I submit through ajax, and returns an updated chunk
I have a form that get's processed via jQuery Ajax. Everything works well on
I have a fairly simple login form that is submitted with a jQuery AJAX
I would like to have a form that can submit to two different action
In my iOS application I have made a form that should submit data into

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.