:
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