Try the below function
function AllowNumbers(e, field) {
var val = field.value;
var re1 = /(^[0-9$]+)/g;
val = re1.exec(val);
if (val) {
field.value = val[0];
} else {
field.value = "";
}
}
and call this function on keyup of a textbox
2
solved Regex to allow only numbers and $ symbol [closed]