JavaScript verification Email (3 ways) _javascript Tips

Source: Internet
Author: User
Tags chr

Today for you to recommend three kinds of JavaScript verification email method, I hope to help you learn.
First: JavaScript Verify mailbox format

<script language=javascript runat=server>
function Isemail (stremail) {
if (Stremail.search (/^\w+ +)| (\.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+) *\. [a-za-z0-9]+$/)!=-1) return
true;
else
alert ("Oh");
}
</SCRIPT>
<input type=text onblur=isemail (this.value) >

Second: Use JavaScript to verify that email is correctly filled in

 
 

The third type: JS verification email

function Char_test (CHR)//character detection functions {var i; 
var smallch= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
var bigch= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
for (i=0;i<26;i++) if (Chr==smallch.charat (i) | | Chr==bigch.charat (i)) return (1); 
return (0); 
} function Spchar_test (CHR)//numeric and special character detection function {var i; 
var spch= "_-.0123456789"; 
for (i=0;i<13;i++) if (Chr==spch.charat (i)) return (1); 
return (0); 
function Email_test (str) {var i,flag=0; 
var at_symbol=0; 
Location of "@" detected var dot_symbol=0; “.” 
The detected position if (Char_test (Str.charat (0)) ==0) return (1); 
 The first character must be in the letter for (i=1;i<str.length;i++) if (Str.charat (i) = = ' @ ') {at_symbol=i; 
 Break 
}//Detect "@" position if (At_symbol==str.length-1 | | at_symbol==0) return (2); 
No mail server domain name if (at_symbol<3) return (3); 
The account number is less than three characters if (at_symbol>19) return (4); 
 Account number is more than 19 characters for (i=1;i<at_symbol;i++) if (Char_test (Str.charat (i)) ==0 && spchar_test (Str.charat (i)) ==0) 
return (5); for (i=at_symbol+1;i<str.length;i++) if (char_test Str.charaT (i)) ==0 && spchar_test (Str.charat (i)) ==0) return (5); 
Cannot use other special characters for (i=at_symbol+1;i<str.length;i++) if (Str.charat (i) = = '. ') dot_symbol=i; 
for (i=at_symbol+1;i<str.length;i++) if (dot_symbol==0 | | dot_symbol==str.length-1)//Simple detection has "." To determine whether the server name is legitimate 
 
return (6); 
return (0);
 Mail name Valid}

Above is the JavaScript authentication email method, everybody learns?

Related Article

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.