using javascript to check if string is numbers only this is what i have but its not running any suggestions would the appreciated thanks much in advance. also if it is a string of numbers only then all numbers after the first two digits should be masked.
var start = function RenderRC(CodeOwner) {
var pattern = /^\d+$/;
var Rcode = CodeOwner.toString();
if (Rcode.valueOf.match(pattern)) {
if (Rcode.length > 2) {
var newcode = Rcode.substr(0, 2) + Array(Rcode.length - 2 + 1).join("*");
return newcode;
}
} else {
return Rcode;
}
};