<input type= "text" id= "UID" onblur= "Mail ()"/>//text box, to trigger the loss of focus when the mailbox or phone number format is correct, do not respond correctly, error output ("The user name of the mailbox or phone number format is incorrect" )
function Mail() { varPatten2=NewREGEXP (/^[0-9| a-z|_]{1,17}[@][0-9| a-z]{1,3}. (COM) $/)//e-mail Regular expression varPatten1 =NewREGEXP (/(\d{11}) |^ ((\d{7,8}) | ( \D{4}|\D{3})-(\d{7,8}) | (\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}) | (\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})) $/)//mobile phone number Regular expression (11-digit mobile phone number3-4-bit area code, 7-8-digit live number, 1-4 digits extension number)var Mail= document.getElementById ("UID").value; if(Patten1.test (Mail)|| Patten2.test (Mail)) { } Else{alert ("The user name's mailbox or phone number is not formatted correctly"); } }
Regular Expressions: Mailbox format and phone number (3-4-bit area code, 7-8-digit live number, 1-4 poorly transposition number)