Javascript uses regular expressions to check the validity of user names
User names such as email addresses and mobile phone numbers are frequently verified during user logon and user registration. common expressions are used.
The expression verification for the email address and mobile phone number is as follows:
Function checkUser () {var userName = document. getElementById (user_indium ). value; var sEmailReg =/^ [w-] + (. [w-] +) * @ [w-] + (. [w-] +) + $/; var sNumReg =/^ d + $/if (userName. length <= 0 | userName = enter the email account/mobile phone number) {showTips (the user name cannot be blank !); Return false;} if (sNumReg. test (userName) {if (userName. length! = 11) {showTips (incorrect mobile phone number format !); Return false;} showTips (); return true;} if (! SEmailReg. test (userName) {showTips (Incorrect email address. Please enter it again !); Return false;} showTips (); return true ;}