JS Verify name, email, phone number

Source: Internet
Author: User

< SCRIPT type="text/javascript">

varredflag=0;

    // Name Verification

functionisname(){

varname=$(' #name '). Val ();

if(name. Search (/^[\u0391-\uffe5\w]+$/)!=-1) {

redflag=0;

returntrue;     

       }

Else {

alert (" Malformed name");

redflag=1;

returnfalse;

       }

    }

    // Mailbox Verification

functionisemail(){

varemail=$(' #email '). Val ();

if(email. Search (/^ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9][email protected] ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+\. (?: COM|CN) $/)! =-1) {

//if (Email.search (/^ ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9][email protected] ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9]+\.+[c][o][m]$| C [n]$/)! =-1) {

//if (Email.search (/^ ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9][email protected] ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9]+\. [A-za-z] {2,3}$/)! =-1) {

//if (Email.search (/^.+\@ (\[?) [A-za-z0-9\-\.] +\. ([a-za-z]{2,3}| [0-9] {1,3}) (\]?) $/)! =-1) {

//if (Email.search (/^\w+ (-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/)! =-1) {

redflag=0;

returntrue;     

       }

Else {

alert (" bad mailbox Format");  

redflag=1;

returnfalse;

       }

    }

    // Verify phone number

functionfucchecktelphone()

    {        

vartelphone=$(' #telephone '). val();

if(telphone. Search (/^ ([0\+]\d{2,3}-)? ( 0\d{2,3})? (\d{7,8}) (-(\d{3,}))? $/)!=-1) {

redflag=0;

returntrue;

       }

Else {

alert (" wrong phone format");  

redflag=1;

returnfalse;

       }

    }

    // Verify your phone number

functionfucchecktel()

    {        

varTel=$(' #tel '). Val ();

if(Tel. Search (/^ ((13[0-9]{1}) | ( 15[0-9]{1}))) +\d{8}) $/)!=-1) {

redflag=0;

returntrue;     

       }

Else {

alert (" phone format error");  

redflag=1;

returnfalse;

       }

    }

// verify QQ

functionisqq()

    {         

varqq=$(' #qq '). Val ();

if(QQ. Search (/^[1-9]\d{4,8}$/) != - 1 ){   

redflag=0;

returntrue;     

       }

Else {

alert ("QQ format error");  

redflag=1;

returnfalse;

       }

    }

//msn Verification-(as with the mailbox)

functionismsn()

    {         

varmsn=$(' #msn '). Val ();

if(msn. Search (/^\w+ (-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/)!=-1) {

redflag=0;

returntrue;     

       }

Else {

alert ("MSN format Error");  

redflag=1;

returnfalse;

       }

    }

    // Birthday Verification

functionisbirthday()

    {         

varDay=$(' #birthday '). Val ();

if(day. Search (/\d{1,4}\-\d{1,2}\-\d{1,2}/) != - 1 ){  

//varzzbds= "([0-9]{3}[1-9]|[ 0-9]{2}[1-9][0-9]{1}| [0-9] {1} [1-9] [0-9] {2}| [1-9] [0-9] {3}) -(((0[13578]|1[02))-(0[1-9]|[ 12][0-9]|3[01]) | ((0[469]|11)-(0[1-9]|[ 12][0-9]|30)) | (02-(0[1-9]|[ 1][0-9]|2[0-8]))) | (([0-9]{2}) (0[48]|[ 2468][048]| [13579] [26]) | ((0[48]| [2468] [048]| [3579] [26]) (xx)) -02-29) ";

//if (Day.search (ZZBDS)! =-1)

redflag=0;

returntrue;     

       }

Else {

alert (" bad Birthday format");  

redflag=1;

returnfalse;

       }

    }

function NextStep () {

//if (redflag==0) {

// document.form0.submit ();

//}else{

// return;

       //}

if(isname()&&isbirthday() &&isemail()&&fucchecktelphone() && Fucchecktel ()&&isqq()&&ismsn() ){

document. Form0 . Submit ();

}else{

return;

       }

    }

</ SCRIPT >

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.