I have a form field in which I am using maskmoney
, but when the number entered enters the thousand, number_format
returns only the first four decimal places.
Calling maskmoney
:
$(function(){
$("#Cultsal").maskMoney({symbol:'R$ ',
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
The field input
:
<label for="Cultsal">Digite o valor</label>
<input id="Cultsal" name="Tultsal" type="text" size="10">
The php:
echo "O valor digitado foi de R$ ". number_format($ultsalbase, 2, ",", ".");
However, when the output is a thousand, the php returns only the first four digits. For example, if you enter 1000, the maskmoney has 1,000.00, but the php returns 10.00. Up to a hundred works normal, type, I enter with 100, maskmoney
shows 100.00 and php returns 100.00. It only gives a prolema when it passes into the thousand.
Is there a solution, or do I have to use another mask?
Edit: I need number_format
because when I use the value in a function with another variable, it does not "inherit" the formatting properly (it does not include the ", 00", sometimes puts .000 etc). For example:
if ($tiposal=="hora") {
$rem = ultsalbase * $multipl;
}
Even though I put the number_format
only in the other variable ( $rem
in case) it gives the same error.