I have a javascript function that I use to validate a Number Only field.

I am not good with RegEx yet..

I have a problem where the field allows 20+ to be entered and it crashes the Number only datatype on submit.

How do I change it so the + symbol is removed? Also any character other than a digit? Cause they will enter 24k too for example, or 5mil

Existing function:

function numOnly(fld) {
fld.style.backgroundColor="white";
var reNum = /(^-?\d\d*$)/ig; // only digits allowed -- no text please
var val = parseFloat(fld.value.replace(/[\s\,\\+\$]/g, "")); // remove spaces, commas and dollar signs
if (!reNum.test(val)) {
// alert("The value " + fld.value + " is not a valid number or currency for " + fld.name +".");
fld.style.backgroundColor="#F60";
fld.focus();
var popHelp = window.open("/SBDX/Scripts/popHelp.asp?ID=" + fld.name + "&err=validation", "popErr", "resizable=1,height=300,width=400")
popHelp.focus();
val = null;
}
return val;
}



Help very appreciated.