Finding the Unterminated...

wxdqz

New Member
Im relatively new to coding javascript as I am a VBScript devotee. I have come across a bit of code I wish to use to validate a phone number. Doesnt seem that hard at all, but when I run the code I came up with, I get an "Unterminated String Constant" error. I have tried to find it, but it remains invisible to me:

Data supplied: "(215) 555-1212"

Code to check a valid phone number:

if (e.phoneNumber) {
num = e.value;
num = stripChar(num, " ");
num = stripChar(num, "-");
num = stripChar(num, "+");
num = stripChar(num, "/");
num = stripChar(num, "\");
num = stripChar(num, "(");
num = stripChar(num, ")");

if (!isNumber(num)) {
invalid_phoneNumber = true;
}
else {
if (num.length < 10) {
invalid_phoneNumber = true;
}
}
}

Referenced code to strip Characters:

function stripChar(sValue, sChar) {
var i, tempChar, buildString;
buildString = ""
for (var i=0; i<sValue.length; i++) {
tempChar = sValue.charAt(i);
if (tempChar != sChar) {
buildString = buildString + tempChar;
}
}
return buildString;
}

Referenced code to check if string is numerical:

function isNumber(value) {
for (var i=0; i < value.length; i++) {
a = parseInt(value.charAt(i));
if (isNaN(a)) {
return false;
break;
}
}
return true;
}

Thank you all in advance for your help!
 
Back
Top