Monday, June 2, 2008

Javascript:Phone Number

var validChars = ", +-0123456789()";

if(document.getElementById(FinalControlID17).value.trim() !="")
{
var sControlValue = document.getElementById(FinalControlID17).value.trim();
for (var i = 0; i < sControlValue.length; i++)
{
if(validChars.indexOf(sControlValue.charAt(i)) == -1)
{
alert ("Please enter a valid Phone Number");
document.getElementById(FinalControlID17).select();
return false;
}
}

}

No comments: