Paste Inputs with type="money"

1
$(function() {
    $("input[name*='pvn'").maskMoney({
        thousands : '.',
        decimal : ','
    });
})

I do this to get the inputs with name='pvn' and apply a mask, but I would like to apply this mask to all money fields, so I do not need to do a function for each input.

    
asked by anonymous 18.10.2016 / 16:03

1 answer

3

Just use the selector: [type=money]

$(function() {
  $('[type=money]').maskMoney({
    thousands: '.',
    decimal: ','
  });
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"type="text/javascript"></script>
<label for="valor1">Valor 1</label>
<input type="money" id="valor1" />|
<label for="valor2">Valor 2:</label>
<input type="money" id="valor2" />
    
18.10.2016 / 16:10