Herman Eshard Herman Eshard - 4 months ago 18
PHP Question

Can I Masking Input type number in php, but keep the original value when I post the data

I have a problem with masking input type into currency and thousand separator with decimal like " $ 100,000,00 " I found jquery-maskMoney can solve my problem but I need the original integer value like "100000" when I post, so I can easily process it.

This is the example of the Jquery Maskmoney code that I found

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.maskMoney.js" type="text/javascript"></script>
<input type="text" id="currency" />
$(function() {

This code works so well for me, but when I post, I can't get the original value, so the point is, I want to mask the input type with currency and decimal, and I want to POST the original value. Please help me. Thank you


You can use PHP's string replace method when posting.

$a = $_POST['currency']
$b = str_replace(',', '', $a );

This replaces all $a with nothing, The first parameter is the character you want to replace, and the second is what you want to replace it with.


Here is the link of the jquery mask money, reading through it gives a lot more options. https://github.com/plentz/jquery-maskmoney

Also here is i think what you're looking for

enter image description here