Converter Moeda Padrao americano

converter moeda padrao americano para padrao BR

HTML

<!DOCTYPE html>
<html>
<body>

<p id="demo" >Click the button to change the text in this paragraph.</p>
<input type="text" class="form-control" name="TOTAL_FINANCEIRO" id="TOTAL_FINANCEIRO" value="2121">

<label>resultado</label>
<input type="text" class="form-control" name="valorConvert" id="valorConvert">


<button onclick="numeroParaMoeda();">Try it</button>
<button onclick="convertermoeda();">Try</button>

<script>
function numeroParaMoeda(n, c, d, t)
{

    c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");



}
function convertermoeda(){
var b = numeroParaMoeda(document.getElementById("TOTAL_FINANCEIRO").value);
document.getElementById("valorConvert").value = b;
}


</script>

</body>
</html>