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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:03:10+00:00 2026-06-09T00:03:10+00:00

what I am trying to do is pretty simple (I hope): I am trying

  • 0

what I am trying to do is pretty simple (I hope):
I am trying to validate POST data (or any data provided via variable) with Form_Validation.
The problem is that to run actual validation I/we need to do

if ($this->form_validation->run() == FALSE){
 //validation did not pass
}else{
 //validation did pass
}

my set of rules are like this:

$this->form_validation->set_rules('key', '', 'trim|required'); //simplified

so, I am sending data via AJAX to this script obviously

echo $_POST['key']; //prints valid value that is sent from AJAX

How can I validate $_POST[‘key’] using form_validation?

AJAX code

$("#key-inputs .short, #key-inputs .long").change(function () {
        var key = $(this).val();
        var id = $(this).attr('name');
        var table = $(this).attr('class');
        var file = $('span .file').val();
        var data = 'NULL';
        $.post(file + "/edit",{
                        id:id,
                        key:key,
                        file:file,
                        table:table},
                        function(code, textStatus) {
                        data = code;
        });
        $(this).ajaxStop(function(){
            if (data == 3) $(this).parent().fadeOut('slow', function() {}); //delete
            if (data == 2) $(this).fadeOut(200).fadeIn(200); //update
            if (data == 5) alert('not valid'); //update parameter is not valid input (depends on set_value rules)
            //writeConsole(previous.val().outerHTML);
        });
    });

PHP code //simplified

if (!$this->input->is_ajax_request()) redirect('lang/translate/keys/'.$param);
          //do work here
         if ($key == "") {
          //delete key
            $this->lang_translate_model->DeleteKey($id, $table);
            echo 3;
            return TRUE;
         }
         $this->form_validation->set_rules('key', 'key', 'trim|required|max_length[56]|xss_clean|unique_file[lang_key:'.$param.']');
         if ($this->form_validation->run() == FALSE){
          //validation did not pass
          echo 5;
        }

so I have some (generated) inputs, on change I want to make update in DB only if ..set_rules passes.
if input is empty it deletes itself (this works fine)

SOLUTION
TRUE/FALSE table is here

if ($this->form_validation->required($key)){
          //validation did not pass
          echo 5;
}

if there is parameter to pass for example min_length[2];

$this->form_validation->min_length($key,'2');
  • 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-09T00:03:14+00:00Added an answer on June 9, 2026 at 12:03 am

    See this. Also check out the note below on that page.

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

Sidebar

Related Questions

I'm trying to create a pretty simple scatter plot with two data series. I
So I'm trying to do a pretty simple contenteditable list with HTML that looks
I have what I hope to be a pretty simple problem. I'm very simply
Hope your all enjoying your hollydays. Ive run into a pretty funny problem when
I'm trying to render a pretty simple data structure using RABL, but I can't
I have a pretty simple local service that I'm trying to bind to my
I'm trying to do something that should be pretty simple - but it's doing
What i'm trying to do is pretty simple.I want to merge two maps. Say
I'm trying to develop a pretty simple (for now) wrapper class around int ,
I'm trying to create a pretty simple WPF interface, and from what I know

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.