Javascript verification email

Source: Internet
Author: User

 First: javascript verification email format <br/> <script language = JavaScript runat = Server> <br/> function isemail (stremail) {<br/> If (stremail. search (/^/W + (-/W +) | (/. /W +) */@ [A-Za-z0-9] + ((/. |-) [A-Za-z0-9] + )*/. [A-Za-z0-9] + $ /)! =-1) <br/> return true; <br/> else <br/> alert ("oh "); <br/>}< br/> </SCRIPT> <br/> <input type = text onblur = isemail (this. value)> </P> <p> type 2: use JavaScript to verify whether email is entered correctly <br/> <HTML> <br/> <pead> <br/> <title> test </title> <br/> <MCE: script Language = "JavaScript"> <! -- <Br/> function emailcheck () {<br/> var emailstr = document. all. form1.tel. value; <br/> alert (emailstr); <br/> var emailpat =/^ (. + )@(. +) $/; <br/> var matcharray = emailstr. match (emailpat); <br/> If (matcharray = NULL) {<br/> alert ("the email address must include (@ and .) ") <br/> return false; <br/>}< br/> return true; <br/>}< br/> // --> </MCE: SCRIPT> <br/> </pead> </P> <p> <body> <br/> <form name = "form1"> <br/> <input type = "text" name = "tel"/> <br/> <input type = "button" value = "Press" onclick = "emailcheck () "/> <br/> </form> </P> <p> </span> <br/> </body> <br/> </ptml> </ p> <p> 3: <br/> JS verification email <br/> function char_test (CHR) <br/> // character detection function <br/>{< br/> var I; <br/> var smallch = "abcdefghijklmnopqrstuvwxyz"; <br/> var bigch = "abcdefghijklmnopqrstuvwxyz"; <br/> for (I = 0; I <26; I ++) <br/> If (CHR = smallch. charat (I) | CHR = bigch. charat (I) <br/> return (1); <br/> return (0); <br/>}</P> <p> function spchar_test (CHR) <br/> // number and special character detection function <br/>{< br/> var I; <br/> var spch = "_-. 0123456789 "; <br/> for (I = 0; I <13; I ++) <br/> If (CHR = spch. charat (I) <br/> return (1); <br/> return (0); <br/>}</P> <p> function email_test (STR) <br/>{< br/> var I, flag = 0; <br/> var at_symbol = 0; <br/> // "@" detected location <br/> var dot_symbol = 0; <br/> // ". "detected location <br/> If (char_test (Str. charat (0) = 0) <br/> return (1 ); <br/> // the first character must contain letters </P> <p> for (I = 1; I <Str. length; I ++) <br/> If (Str. charat (I) = '@') <br/>{< br/> at_symbol = I; <br/> break; <br/>}< br/> // check the "@" position </P> <p> If (at_symbol = Str. length-1 | at_symbol = 0) <br/> return (2 ); <br/> // No email server domain name </P> <p> If (at_symbol <3) <br/> return (3 ); <br/> // The account contains less than three characters </P> <p> If (at_symbol> 19) <br/> return (4 ); <br/> // The account contains more than 19 characters </P> <p> for (I = 1; I <at_symbol; I ++) <br/> If (char_test (Str. charat (I) = 0 & spchar_test (Str. charat (I) = 0) <br/> return (5); <br/> for (I = at_symbol + 1; I <Str. length; I ++) <br/> If (char_test (Str. charat (I) = 0 & spchar_test (Str. charat (I) = 0) <br/> return (5 ); <br/> // other special characters cannot be used </P> <p> for (I = at_symbol + 1; I <Str. length; I ++) <br/> If (Str. charat (I) = '. ') dot_symbol = I; <br/> for (I = at_symbol + 1; I <Str. length; I ++) <br/> If (dot_symbol = 0 | dot_symbol = Str. length-1) <br/> // check whether ". <br/> return (6); </P> <p> return (0 ); <br/> // The email name is valid <br/>}

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.