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