Regular Match Mailbox----full

Source: Internet
Author: User

Comma-wrap, continuous validation

Code:

<! DOCTYPE html>
<meta charset= "UTF-8" >
<script src= ". /jquery-3.1.0.js "></script>
<title> Email Verification </title>
<style type= "Text/css" >
textarea{
height:200px;
width:400px;
BORDER:3PX solid #FF69B4;
font-size:30px;
}
. green{
Color:blue;
}
. red{
color:red;

}
button{
width:200px;
height:50px;
font-size:40px;
Font-weight:bold;

Background-image:linear-gradient (Pink,lightblue,lightgreen);

}
</style>
<body>
<textarea></textarea><br>
<button class= "BTN" > Submit Verification </button>
<div>
<p class= "Green" > </p>
<p class= "Red" ></p>
</div>
</body>
<script type= "Text/javascript" >

var emailreg =/^\[email protected][a-z-0-9]+ (\.[ a-za-z0-9-]+)? \. ([a-za-z0-9\u4e00-\u9fa5]{2,8}) (\.cn)? $/

Console.log (Emailreg.test (' [email protected] '))
Console.log (Emailreg.test (' [email protected] '))
Console.log (Emailreg.test (' [email protected] China my '))
Console.log (Emailreg.test (' [email protected] '))


[\u4e00-\u9fa5]{2}

Splitting the regular
var Splitreg =/[;,\r\n\s,]+/

$ (function () {

$ (' button '). On (' click ', function () {

Declaring an empty string
var str = "

var emailallstr = $ (' textarea '). Val ();
Split into an array of emails
var Emailallarr = (emailallstr + '; '). Split (Splitreg)


Delete the last empty element
Emailallarr.pop ()
Console.log (Emailallarr)


Emailallarr.foreach (function (ele) {
Console.log (Ele)
if (Emailreg.test (ele)) {
Console.log (Ele)
str + = (' <p class= ' green > Email ' + ele + ' verified success! </p> ')
}else {
str + = (' <p class= ' red ' > email ' + ele + ' verification failed! </p> ')
}
})

$ (' div '). html (str)
})

})

</script>

Regular Match mailbox----full

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.