I am looking for a standard phone number validation script. Mine is below, but it's a bare minimum. I'd like something a little more robust without having to reinvent the wheel.
If you have one you'd be willing to share, I'd appreciate it.
JB
function isPhoneNumber(inputVal)
{
inputStr = inputVal.toString()
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i)
if (!(oneChar == "(" || oneChar == "
" || oneChar == "-" || (oneChar >= "0" && oneChar <= "9"
))
{
alert("Phone Number must contain numbers, parentheses and dashes only. Invalid Character was:" + oneChar)
document.forms(0).txtPHONE.value = ""
document.forms(0).txtPHONE.focus()
return
}
}
return true
}
If you have one you'd be willing to share, I'd appreciate it.
JB
function isPhoneNumber(inputVal)
{
inputStr = inputVal.toString()
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i)
if (!(oneChar == "(" || oneChar == "
{
alert("Phone Number must contain numbers, parentheses and dashes only. Invalid Character was:" + oneChar)
document.forms(0).txtPHONE.value = ""
document.forms(0).txtPHONE.focus()
return
}
}
return true
}