asked on
ASKER
ASKER
function checkPhoneNumber(field)
{
if (field.value.length < 14)
{
alert("wrong input");
return false;
}
}
with mask: \(\d{3}\) \d{3}-\d{4}
without mask: \d{10}
(which allows for leading and trailing zeroes, but not for spaces or anything not a digit, and the digits must be 10 in total)
ASKER
function checkPhoneNumber(field)
{
var re = new RegExp("\\d{10}"); // note the extra backslash
if (!field.value.match(re))
{
alert("wrong input");
return false;
}
}
ASKER
var re = new RegExp("\\d{3}- \\d{3}-\\d{4}"); // note the extra backslash
if (!theForm.homePhone.value.match(re))
{
alert("The phone number is either blank or contains the wrong length. Phone must be 10 digits. Please make sure you included an area code.\n");
theForm.homePhone.focus();
return false;
}
Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.
TRUSTED BY
Usually, JavaScript is used for light validation (i.e., without the need to access a db) and the server is used for full validation.