Home>

Let's take a look at what mailboxes are available:

If we judge each mailbox,Obviously impossible.

— A complete internet mail address consists of the following two parts,The format is:[email protected]In the middle is separated by a symbol "@" which means "" (at), the left side of the symbol is the other's login name,On the right is the full host name,It consists of a host name and a domain name. Among them, the domain name consists of several parts,Each part is called a subdomain, and each subdomain is separated by a dot ".". Each subdomain will tell users some information about this mail server.

Regular expression for key validation:var myreg=/^([\.a-za-z0-9_-])[email protected]([a-za-z0-9_-])+(\.[a-za-z0-9_-])+/;Verify input box:

//Verify email
     function vailemail () {
       var email=jquery ("#​​email"). val ();
       var flag=false;
       var message="";
       var myreg=/^([\.a-za-z0-9_-])[email protected]([a-za-z0-9_-])+(\.[a-za-z0-9_-])+/;
       if (email == "") {
         message="Mailbox cannot be empty!";
       } else if (! myreg.test (email)) {
         message="Please enter a valid email address!";
       } else if (checkemailisexist ()) {
         message="This email address is already registered!";
       } else {
         flag=true;
       }
       if (! flag) {
          //Error message
         //jquery("#emaildiv").removeclass().addclass("ui-form-item has-error ");
         //jquery ("#​​emailp"). html ("");
         //jquery("#emailp").html("<i class=\ "icon-error ui-margin-right10 \"><\/i>"+ message);
         //jquery ("#​​email"). focus ();
       } else {
         //Prompt correctly
         //jquery("#emaildiv").removeclass().addclass("ui-form-item has-success ");
         //jquery ("#​​emailp"). html ("");
         //jquery("#emailp").html("<i class=\ "icon-success ui-margin-right10 \"><\/i>the mailbox is available ");
       }
       return flag;
     }

Write a method to verify

//Verify that the mailbox exists
     function checkemailisexist () {
       var email=jquery ("#​​email"). val ();
       var flag=false;
       jquery.ajax (
        {url:"checkemail?t =" + (new date ()). gettime (),          data:{email:email},          datatype:"json",             type:"get",             async:false,             success:function (data) {
             var status=data.status;
             if (status == "1") {
               flag=true;
             }
           }
      });
      return flag;
     }

Background processing program:

@requestmapping (value="/checkemail", method=requestmethod.get)
  public void checkemail (httpservletrequest request, httpservletresponse response) {
    map<string, object>map=new hashmap<string, object>();
    try {
      string email=request.getparameter ("email");
      string status="0";
      //Write query statement,Check whether the mailbox exists in the table
      //userbaseinfo userbaseinfo=userservice.finduserbyemail (email);
      //if (userbaseinfo!=null) status="1";
      map.put ("status", status);
      string data=jsonobject.fromobject (map) .tostring ();
      response.getwriter (). print (data);
      response.getwriter (). flush ();
      response.getwriter (). close ();
    } catch (exception ex) {
    }
  }
  • Previous Nginx server installation and some basic configuration summary
  • Next Summary of commonly used javascript form validation