JS Verify that the fixed phone can only be digital authentication code

Source: Internet
Author: User

JS Authentication fixed Phone: can only be a number. and have the corresponding format//028-67519441 or 0839-8777222 or 028-6545124

function Check_validate (value) {
var reg =/^ (d{3,4})-(d{7,8})/;
if (Value.constructor = = string) {
var re = Value.match (reg);
return true;
}
return false;

Instance Code two

Telephone number, fax

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 ();
}
}
}


Verify code Two

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 ();
}
}
}

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.