Background: is a thick book ah, want to write good also not easy, but daily also on those like telephone, mailbox, mobile phone, a bunch of online, but really good verification, but also have to understand a bit of regular knowledge, and then more testing the:-)
The following mailbox is:
Underlined: In the name of the field of rice is said to be the name of the pole, the domain name of the shoulder pole because of input more trouble, it seems more irregular, is not much value, the current investment is relatively few people. By the standards of DNS, domain names are not allowed to be underlined.
Underline: Some people in the registration of the user name likes to use the underscore _, this user name in the mailbox when the trouble, send you an email is also very inconvenient.
Two-level domain name mailbox is basically eliminated, this buddy can write underline, expand the scope but the problem is not big, mainly from the prompt users can be.
com.cn Domain name support: (\.[ a-za-z0-9-]{2,3}) {1,2} com.cn
——————————————————————————————————————————————————————————————
Emailpreg =/^[a-za-zd]+ ([-_.] [a-za-zd]+) *@ ([a-za-zd]+[-.]) +[a-za-zd]{2,5}$/; The QQ number of the mailbox can not verify.
Emailpreg =/^ ([a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + ((\.[ a-za-z0-9_-]{2,3}) {1,2}) $/;//dfdfd1212@dfdfd.abc.cn are two-level mailboxes. abc@12df1.com.cn
Emailpreg =/^ ([a-za-z0-9_-]) +@ ([a-za-z0-9-]) + ((\.[ a-za-z0-9-]{2,3}) {1,2}) $/; //domain name is not allowed to underline, remove the underline, this is the last regular. As for what the first letter can not be underlined, to do so, this will have to be lengthened ... User is also not SB, just play a certain hint role, don't complicate, so far.
<dd><input id= "2" rel= "Mailbox" res= ' 2 ' type= "text" class= "item-edit-txt" name= "2" value= "<{$ User.email}> "></dd>
}else if ($ (this). attr (' res ') = = ' 2 ' &&!emailpreg.test ($ (this). Val ())) {/ /from QQ login over the user's large network interface to get the mailbox, let it fill out.
$ (this). CSS ("Border", "1px solid #f00");
$ ("#" +$ (This). attr (' res ') + ' span '). Remove ();
$ ("#" +$ (This). attr (' res '). After ("<span id=" +$ (This). attr (' res ') + ' span ' + ' ><br/> ' +$ (this). attr (" Rel ") +" incorrect format </span> ");
$ (this). focus ();
res = false;
return false;
——————————————————————————————————————————————————————————————
JavaScript form verification email, Determine whether an input is a mailbox email, implemented through regular expressions.
The above is a small series for everyone to collect the daily JS mailbox verification Regular expression, I hope you like.