Currency mask with jquery [duplicate]

0

I need a tag for a field with value, I'm using jquery.maskinput works perfect but I have to type the whole value!

What I'm looking for is a mask that fills in automatic "R $ $ var.000,00"

For example, if I have a value of 500mil, with maskinput I would have to type

50000000

But with the mask I mentioned above, you would only have to type

500

Anyone have any tips on this ??

    
asked by anonymous 01.03.2017 / 00:45

2 answers

1

Without doing any validation, just to get what you quoted.

$('input').on('keyup', function() {

var v = $(this).val();

if (parseInt(v.length) === 3) {

$(this).val((v * 1000).toLocaleString('pt-br', {style: 'currency', currency: 'BRL'}));

}

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="text" />
    
01.03.2017 / 01:29
0

There is a jQuery plugin that might help, if it is called jquery-maskmoney , follow the link:

link

    
01.03.2017 / 01:43