I'm trying to change a value user enters to a true number (ex. 15 or 144.38). If it has unapproved characters (ex. $,) then they should be stripped. Also if user enters value with multiple periods (ex. 43.14.14) then I want to clear entire value. I was able to do step 1 but can't figure step 2, please advise. Here's my code so far http://jsbin.com/otawiVa/1
function myFunction()
{
var str = document.getElementById("number_field").value;
var res = str.replace(/[^0-9.}]/g,"");
document.getElementById("approved_number").innerHTML=res;
}