-2
How do I allow the % symbol inside the input using jQuery Mask
?
I ask this, because in the same field will have case that it is used as currency formatting 1.000.000,00
or just percentage 2.50%
.
$(document).ready(function() {
$('.moeda').mask("#.##0,00", {reverse: true});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://igorescobar.github.io/jQuery-Mask-Plugin/js/jquery.mask.min.js"></script>
Taxa:
<input id="formaTaxas" name="formaTaxas" type="text" class="form-control moeda" value="0,00" required/>
But the value "2.50%" is not a monetary format, so why use maskMoney?
– Woss
@Andersoncarloswoss I missed the name, it’s not maskMoney, it’s
jQuery Mask
. Do you know how I can use the symbol of %?– Tiago
If you really want to use JS (which I wouldn’t), try using the percentage code: UNICODE. U+00025. HEX CODE. % HTML CODE. % HTML ENTITY. % CSS CODE. 0025. <span>%</span> content: " 0025";
– Edward Ramos
@Edwardramos what suggestion would you give? It doesn’t have to be exactly
JS
, I just need it to work.– Tiago
Just leave it outside the
input
or would mention in the title Ex: "Estimated Profit (%)". But if you want to use the % within theinput
, try using any of the above comment codes.– Edward Ramos