I am looking for a way to place an automatic . (dot) or , (comma) for every multiple of 3.

I only find the mask to do so but it requires the user to input the exact amount of numbers:

<script type="text/javascript">
$(function() {
  $.mask.definitions['~'] = "[+-]";
    $("input").blur(function() {
    $("#info").html("Unmasked value: " + $(this).mask());
    }).dblclick(function() {

like the above code requires the user to enter (9 numbers) - I would like the user to be able to enter any number he wants and still automatically placing .(dot) for every multiple of 3.

3 Years
Discussion Span
Last Post by matrixdevuk

I still do not understand how to use it:

Here is part of my codes:

Normally it works, without the number format (except for the dot for every multiple of 3) and normally I use integer for the data type. Now, I am using varchar.


function numberformat(num)
    result = num.toFixed(3);
    return result;

if (isset($_POST['ok'])){

        if (empty($_GET['package_id']))
            $sqlstr = "INSERT INTO `package`(package_id, package, price) VALUES('".$package_id."','".$package."','".$price."')";            
            $fprice = numberformat($price);
            $sqlstr = "UPDATE `package` SET package='".$package."', price='".$fprice."' WHERE package_id=".$_GET['package_id'];         

        $result = mysql_query($sqlstr) or die(mysql_error());

        //Jika mode edit, maka tidak akan dikirimkan konfirmasi kepada subscriber
        //if (empty($_REQUEST['id']))   kirimEmail($idKategori, $judul, $news);
        $confirmation = ($result) ? "Data has been saved." : "Fail to save dGagal menyimpan data."; 

I receive this error message:

Fatal error: Call to undefined function numberformat() in C:\xampp\htdocs\administrator\admin\add_package.php on line 126

line 126: $fprice = numberformat($price);

I wonder how to fix the error?


It's number_format, not numberformat. These errors are the most basic errors in PHP. You should be able to read these no problem. You could've found this on Google VERY easily. Stop coming here just to get stuff easy. A little reading never does harm.

Don't take this in a negative way. The more you Google, the more you find out about PHP. The more errors you learn to read, the less you need help.
Oh, and line number is usually a massive hint, and "undefined function" is one, too.

Edited by matrixdevuk

$fprice = number_format($price);
$sqlstr = "UPDATE `package` SET package='".$package."', price='".$fprice."' WHERE package_id=".$_GET['package_id'];
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.