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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:41:49+00:00 2026-06-02T11:41:49+00:00

I have an input which can be decimal or numeric. I want to use

  • 0

I have an input which can be decimal or numeric. I want to use this rule:

$this->form_validation->set_rules('price', 'Price', 'decimal|numeric');

But i think the rules in form_validation helper not working with “or” statement. If the price is something like that “149.99” it’s valid but if the price is “150” it’s not.

Am i missing something or isn’t it possible to use something like that:

 $this->form_validation->set_rules('price', 'Price', 'decimal or numeric');
  • 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-02T11:41:54+00:00Added an answer on June 2, 2026 at 11:41 am

    CI, does not allow to mix datatypes when validating. Instead, Create your custom validation rule.

    Declare a rule like this

    $this->form_validation->set_rules('price', 'Price', 'callback_decimal_numeric');
    

    After create a method on the controller

        public function decimal_numeric($str)
        {
            if ($str <isdecimal&nummeric>) //Use your logic to check here
            {
                $this->form_validation->set_message('decimal_numeric', 'The %s field validation has failed');
                return FALSE;
            }
            else
            {
                return TRUE;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a streaming input which has repeated values. I can use any data
I have an input field which a user can type into. This input also
I have a JSON input which can go to any number of levels. I'm
I have a group which can occur any number of times in the input
I have this strange thing with input and output streams, whitch I just can't
I have an input which is of this form: (((lady-in-water . 1.25) (snake .
I have an input field which I want to restrict so that the user
I have an input text which is this: <div class=editor-label> @Html.LabelFor(model => model.EmployeeId, Employee
I have an input box which I want to handle two types of information,
I have an input text which can be either: URL: http://www.cnn.com Cookie: xxx; yyy

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.