Search code examples
javascriptjquerymasking

jquery mask deletes proceeding values after comma


Noob here, I have an input field that I use simple jQuery mask to add comma like 1000 = 1,000

$('#A3-input').mask('000,000,000,000', {reverse: true});

this works well but my problem is when I do math operation on the masked value the 1,000 value becomes 1?

How to do I get the original value of the input in javascript which is 1000 and not the 1 that jQuery masked produced? below is the javascript code I use to retrieve the value of the input field.

A3 = parseFloat(document.getElementById("A3-input").value);

BTW without the jQuery mask the value is 1000 and my formula works, however when the masking is in effect the value becomes 1.

11,111,111 becomes 11

1,000 becomes 1

45,412,154 becomes 45 etc


Solution

  • After looking for an answer I found the solution from here

    A3 = parseFloat((document.getElementById("A3-input").value).replace(/[^\d\.]/g,''));