Bab,
<script>
function fn(str)
{ var reg = /^[-]?\d*(\.\d{1,2})?/;
return str.match(reg)? str.match(reg)[0] : ""
}
function check(input) {
input.value = fn(input.value) ;
}
</script>
<form method='post' name='forma'>
<input type='text' name='balance' value='' size='11' onchange="check(this);">
</form>