khong cho nhap cham phay

by bvotcode

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<input id="vida_ingreso"  type="text">
	<button id="showit">Get value</button>
</body>
</html>

JavaScript

function autofill(input){
    aux = input.value.replace('$','');
    var num = aux.replace(/\./g,'');
    if(!isNaN(num)){
        num = num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g,'$1.');
        num = num.split('').reverse().join('').replace(/^[\.]/,'');
        input.value = '$'+num;
    }else{
        input.value = '$'+input.value.replace(/[^\d\.]*/g,'');
    }
}

document.getElementById('showit').addEventListener('click', function() {
	var input = document.getElementById('vida_ingreso');
	var repl = input.value.replace(/\$|\./g, '');
	alert(repl);
});