Here's sample of my input format
<script type="text/javascript" src="http://jquerypriceformat.com/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://jquerypriceformat.com/js/jquery.price_format.2.0.js"></script>
<script type="text/javascript" src="http://jquerypriceformat.com/js/ini.js"></script>
<label for="example6">Currency:</label>
<input id="example6" name="example6" value="" type="text">
Mysql table type is set to : decimal(16,2)
Here's my problem:
For example:
Input format: US$ 625,695,295.00
Outout format: 625
It means, it won't save into table as currency correct format, it won't save after comma into sql table. It should be something like this: 625695295.00
How to remove it those commas and dollar sign when data is posting to mysql table?
Here's my post code:
$problem->setExample6($_POST["example6"]);
$_POST["example6"] = $problem->getExample6();
Thanks in advance.
SOLUTION: PROBLEM SOLVED!! SPECIAL THANKS TO chris85 Here we go:
$problem->setExample6(str_replace(array(',', 'US$', ' '), '', $_POST["example6"])); $_POST["example6"] = $problem->getExample6();
Here's a javascript approach you could use to strip the US$
, whitespaces, and commas.
var string = 'US$ 625,695,295.00';
alert(string.replace(/(US\$|\s*|,)/g, ''));
Demo: http://jsfiddle.net/8u51grd9/1/
I'd do this in PHP though.
$_POST["example6"] = str_replace(array(',', 'US$', ' '), '', $_POST["example6"]);