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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:08:18+00:00 2026-06-04T13:08:18+00:00

hi I have a problem on formatted amounts. On my input form, users can

  • 0

hi I have a problem on formatted amounts.
On my input form, users can add and edit a formatted amount. Since this is a multi-language program, users can specify their own format, so there isn’t a fixed pattern.
Examples:

250.000
250,000
250.000,00  
250,000.00

Sadly, I have to “un-format” them, before store them into the database or MySQL will understand my number as floats and viceversa.

How can I overcome this? Any ideas?

  • 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-04T13:08:20+00:00Added an answer on June 4, 2026 at 1:08 pm

    ok, finally I made it, so I’ll share my solution
    First of all, I used Mootools to format the input field while to user is typing.
    Then I moved server side.

    Format options are saved inside my application, so this is the code

    //get decimal separator from saved params
    $dec = $params->get('decimalSep', '.');
    //remove any char that's not a number or decimal separator 
    //(i don't care about thousands sep)
    $regex = '#[^0-9-'.preg_quote($dec).']#';
    
    $normalized = preg_replace($regex, '', $price);
    $normalized = str_replace($dec, '.', $normalized);
    

    Basically I get rid of everything except the decimal separator, then I replace it with the standard one (.).

    It works like a charm.

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

Sidebar

Related Questions

i have this problem: i have a form with textarea field, and on a
Json Problem : I have this formatted JSON { Table1:[ { TableName:LoadDistributor, Description:Distributor ,
i have a problem with reading empty elements formatted like <eanCode/> . After this
I have a problem that output string must be utf8-formatted, I am writing currently
I have problem like this https://dev.twitter.com/discussions/4563 if (webResponse.Headers[Content-Encoding] == gzip) { byte[] bytes =
I have problem with Visual Studio Designer. When I display design of a form,
I have large amounts of data formatted in JSON formats, I recently scripted the
I have an array of strings that are formatted like this: $strings = array(
I've found myself with the following problem: I have form with a random number
I want to display place details from this json: I have problem with parse

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.