JS Check ordinary telephone, fax number

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<TITLE>JS standard telephone, fax number </title>
<script language= "Web Effects" >
Check ordinary telephone, fax number: You can "+" start, in addition to numbers, can contain "-"
function Istel (object)
{
Country code (2 to 3 bits)-area code (2 to 3 digits)-Phone number (7 to 8 digits)-ext (3 digits)

var s =document.getelementbyid (object.id). value;
var pattern =/^ ([0+]d{2,3}-)? ( 0d{2,3})-(d{7,8}) (-(D{3,})? $/;
var pattern =/(^[0-9]{3,4}-[0-9]{7,8}$) | (^[0-9]{7,8}$) | (^ ([0-9]{3,4}) [0-9]{3,8}$] | (^0{0,1}13[0-9]{9}$)/;
if (s!= "")
{
if (!pattern.exec (s))
{
Alert (' Please enter the correct phone number: Phone number format is country code (2 to 3 bits)-area code (2 to 3 digits)-Phone number (7 to 8 digits)-EXT (3) "");
Object.value= "";
Object.focus ();
}
}
}

JS Authentication Phone Number

The phone number is not as fixed as before and the number is escalating. So to make the simplest and most practical number verification
1, in the phone number only allow "0-9", "-", "+"
var cellphone=/^ ([d-+]*) $/;
if (!cellphone.test (Form1.messagephone.value))
{
Alert (' You enter a valid phone number! ');
Form1.messagephone.focus ();
return false;
}


For more details please see: http://www.111cn.net/wy/js-ajax/35354.htm

</script>

<body>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.