The first one:
Copy Code code as follows:
function Checkreg ()
{
Verify the phone number of the phone number, including section 153,159
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}-)? ( 0\d{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;
}
}
if (Document.form.UserMobile.value!= "") {
var Mobile=document.form.usermobile.value;
var reg0 =/^13\d{5,9}$/;
var reg1 =/^153\d{4,8}$/;
var reg2 =/^159\d{4,8}$/;
var reg3 =/^0\d{10,11}$/;
var i = false;
if (Reg0.test (mobile)) My=true;
if (Reg1.test (mobile)) My=true;
if (Reg2.test (mobile)) My=true;
if (Reg3.test (mobile)) My=true;
if (!my) {
Document.form.usermobile.value= ';
Alert (' Sorry, you have entered the phone or PHS number is wrong. ');
Document.form.UserMobile.focus ();
return false;
}
return true;
}
}
Description
The test method checks whether a pattern exists in the string, returns True if it exists, or returns false.
Regular expression section:
\d represents a number
{7,8} represents 7-8 digits (indicates phone number)
{3,} represents an extension number
d{2,3} represents the area code
\+]\d{2,3} represents the international area code
^13\d{5,9}$///130?139. At least 5 digits, up to 9 digits
/^153\d{4,8}$///Unicom 153. At least 4 digits, up to 8 digits
/^159\d{4,8}$///Mobile 159. At least 4 digits, up to 8 digits
The second one:
The code is as follows:
Copy Code code as follows:
var Mobile = $ ("#varMobilePhone"). Val ();
var Phone = $ ("#varPhoneNo"). Val ();
if (Mobile = "" &&phone = "")
{
Alert ("Mobile phone and landline, please fill in at least one contact Method!") ");
$ ("#varMobilePhone"). focus ();
Return
}
if (mobile!= "")
{
if (!ismobil (Mobile))
{
Alert ("Please enter the correct cell phone number!") ");
$ ("#varMobilePhone"). focus ();
Return }
}
Mobile Number Verification Information
function Ismobil (s)
{
var patrn =/(^0{0,1}1[3|4|5|6|7|8| 9][0-9]{9}$)/;
if (!patrn.exec (s))
{
return false;
return true; }
Background validation is as follows:
if (model. Zip!= null)
{
if (! Common.PageValidate.IsValidate (model. Zip, "^\\d{6}$"))
{COMMON.WEBMESSAGE.SHOWMSG (httpcontext.current, "Please enter the correct postcode");
Return
}
}
if (model. Phoneno!= null)
{
if (! Common.PageValidate.IsValidate (model. Phoneno, "\\d{3}-\\d{8}|\\d{4}-\\d{7}"))
{
COMMON.WEBMESSAGE.SHOWMSG (httpcontext.current, "Please enter the correct phone number!") ");
Return
}
}
if (model. Mobilephone!= null)
{
if (! Common.PageValidate.IsValidate (model. Mobilephone, "^0{0,1} (13[0-9]|15[3-9]|15[0-2]|18[0-9]) [0-9]{8}$")]
{
COMMON.WEBMESSAGE.SHOWMSG (httpcontext.current, "Please enter the correct 11-bit valid cell phone number!") ");
Return
}
}