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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:43+00:00 2026-05-22T16:45:43+00:00

UPDATED I’m creating a codeigniter callback for validating an input where users enter programming

  • 0

UPDATED

I’m creating a codeigniter callback for validating an input where users enter programming tags for example php, js, jquery. Values are separated by commas.

I want to show a message if you enter duplicate tags for example php, jquery, php, js where php would be the duplicate.

First in my controller I set the validation rules for the ‘user_tags` input

$this->form_validation->set_rules('user_tags', 'User Tags', 'callback_user_tags_dublicates', 'trim|xss_clean|max_length[100]|regex_match[/^[a-z,0-9+# ]+$/i]');

Then the callback

<?php function user_tags_dublicates($str)
        {
            $val = $str; //the input value (all the CSV)
            $tags = str_getcsv($val); //creates an array of the CSV
            if(count($tags) != count(array_unique($tags))) //if array not equal to unique array it contains duplicates
            {
                $this->form_validation->set_message('user_tags', 'The %s field can not have duplicate tags.');
                return FALSE;
            }
            else
            {
                return TRUE;
            }
        } ?>

and finally in the view I show my error.

<?php echo form_error('user_tags'); ?>

When I enter duplicate tags I get

Unable to access an error message corresponding to your field name.

I’m not sure what I’m doing wrong. I tested the function in a static page without validation rules and it works.

  • 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-05-22T16:45:44+00:00Added an answer on May 22, 2026 at 4:45 pm

    set your error message for user_tags inside your user_tags_dublicates() function

       $this->form_validation->set_message('user_tags', 'The %s field can not have duplicate tags.');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

( Updated a little ) I'm not very experienced with internationalization using PHP, it
UPDATED INFO: OS Windows 7 32bit Apache 2.2.15 PHP 5.2.13 This is really weird.
Updated Here's an even simpler example showing the failure (it should hide the img
Updated script with proper field names. Why isnt this working? <?php $con = mysql_connect(localhost,root,pass);
* *Updated code as of 3-28 Index.php <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
UPDATED I've updated the example to better illustrate my problem. I realised it was
--UPDATED-- I want to empty message in a textarea in callback. Can anyone tell
Updated with clarifications Hello, When our users go to http://mysubdomain.server.com/login they get redirected to
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess

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.