^
|
|
|
javascript noob
Hi there
I have the following script that strips out acceptable non-numeric characters that you would find in a telephone number and then checks to see if it is equal to ten digits. The problem I have is that I can't figure out how I would check for illegal non-numeric characters (characters you wouldn't find in a telephone number).
if (isNaN(strng)) {
var stripped = strng.replace(/[\(\)\.\-\ ]/g, "");
if (stripped.length !10) {
error = "The tel number is the wrong length.\n";
}
}
At the moment, if you enter an illegal non-numeric charater the error "The tel number is the wrong length.\n";
pops up which is understandable because the length of stripped would be more than 10 characters but this would clearly confuse the user.
Any help would be appreciated