Get Inputs with type="money"

Asked

Viewed 2,613 times

1

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

I do this to pick up inputs with name='pvn' and apply a mask, but I would like to apply this mask to all fields of the money type, because then I don’t need to do a function for each input.

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" />

  • It worked great! Thank you!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.