If you only want to keep numbers, then replace everything that isn't a number \d = number.
function test_fn(xxx) {
var xxx = xxx.replace(/[^\d]/g, "");
document.getElementById("fid").value = xxx;
}
The possible regular expressions to use are:
/\D/g //\D is everything not \d
/[^\d]/g //\d is numerical characters 0-9
/[^0-9]/g //The ^ inside [] means not, so in this case, not numerical characters
/[^0-9,\.]/g //. is a wildcard character, escape it to target a .
The g means to match all possibilities of the search, so there is no need to use + to match anything else.
You'll find this tool very useful when working with regular expressions and it has an explanation of the possible characters to use at the bottom right.
.or no one ?