Three JS authentication phone number Code

Source: Internet
Author: User

This three verification phone number of JS code, can only sit machine, can not verify the mobile phone number, of course, the site provides a large number of mobile phone number verification examples and articles Oh,
function Checkphone (phone)
{
Verify the phone number of the phone number, including section 153,159
if (phone== "") {
Alert ("Phone number cannot be empty!") ");
return false;
}
if (Phone!= "") {
var p1 =/^ ([0+]d{2,3}-)? ( 0d{2,3})? (d{7,8}) (-(D{3,}))? $/;
var me = false;
if (p1.test (phone)) me=true;
if (!me) {
Alert (' Sorry, the phone number you entered is wrong. Please use-split ' between area code and telephone number;
return false;
}
}
return true;
}


Phone number Verification Two

if (document.form.phone.value== "" && document.form.usermobile.value== "") {
Alert ("Phone number and cell phone number at least choose one!") ");
Document.form.phone.focus ();
return false;
}
if (Document.form.phone.value!= "") {
var Phone=document.form.phone.value;
var p1 =/^ ([0+]d{2,3}-)? ( 0d{2,3})? (d{7,8}) (-(D{3,}))? $/;
var me = false;
if (p1.test (phone)) me=true;
if (!me) {
Document.form.phone.value= ';
Alert (' Sorry, the phone number you entered is wrong. Please use-split ' between area code and telephone number;
Document.form.phone.focus ();
return false;
}
}

Method Three

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;
}
-------------------------------------------------------------------------------------
The following are validation of the previous inherent rules
2, verify the fixed telephone number
The required format is:
Or add country number: +2--3 bit
or no area code: 7--8 bit
or add 3-bit area code: 7--8 bit
Or add 4-bit area code: 7--8 bit

function Check ()
{
if (Testit () | | Checkphone ())
{
return true;
}
return false;
}

function Testit () {
var filter=/^ ([0+]d{2,3}-)? ( 0d{2,3})? (d{7,8}) (-(D{3,}))? $/;
Return Filter.test (Form1.messagephone.value);
}

function Checkphone ()
{
var filter=/^ ([0+]d{2,3}-)? ( 0d{2,3}))? (d{7,8}) (-(D{3,}))? $/
Return Filter.test (Form1.messagephone.value);
}

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.