Regex to replace everything except numbers and a decimal point
Try this:
document.getElementById(target).value = newVal.replace(/^\d+(\.\d{0,2})?$/, "");
Use this:
document.getElementById(target).value = newVal.replace(/[^0-9.]/g, '');
Removing only decimal part can be done as follows:
number.replace(/(\.\d+)+/,'');
This would convert 13.6667px into 13px (leaving units px untouched).