jquerymaskedinput

Adding inputs that have a mask on them?


How do I add the input values with parsefloat if the input also has a jquery mask attached to it?

I am using jquery maskMoney to give my input 2 decimal places and a $ for the value (i.e. $ 410.00), but if say I had 4 inputs in a column and a total input, I believe I get NaN when I try to add the inputs.

The js file I am using is here or if there is any way to mask an input with a $ and two decimal places and a comma for the thousands (i.e. $ 1,233.00) and can add them up that is all I am looking for. Thank you for your time.


Solution

  • I don't have this plugin available to test but from the link you included it appears you can do something like this.

    <input type="text" id="val1">
    <input type="text" id="val2">
    
    <script type="text/javascript">
        $('#val1').maskMoney();
        $('#val2').maskMoney();
        var result = $('#val1').maskMoney('unmasked')[0] + $('#val2').maskMoney('unmasked')[0]
    </script>