Let's see what mailboxes are available:
It is obviously impossible for us to judge each of our mailboxes.
-A complete Internet mail address consists of the following two sections in the format: login @ host name. Domain Name
The middle is separated by a symbol "@" representing "at", and the left side of the symbol is the other's login name, and the right is the complete host name, which consists of the host name and the domain name. Among them, the domain name consists of several parts, each part is called a subdomain (subdomain), each subdomain uses the dot "." Separated, each subdomain tells the user some information about the mail server.
Key-Validated regular expressions: var myreg =/^ ([\.a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) +/;
Verify input box:
Verify mailbox Function Vailemail () {var email = jQuery ("#email"). Val ();
var flag = false;
var message = ""; var myreg =/^ ([\.a-za-z0-9_-]) +@ ([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 has already been registered!"
";
}else{flag = true;
} if (!flag) {//Error prompt//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{//correct prompt//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 way to verify
Verify that the mailbox exists a
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 handler:
@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, query table whether there is the mailbox
//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) {
}
}
That's jquery. Verify that the mailbox format is the correct instance code, using regular expressions:var myreg =/^ ([\.a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) +/, we can try.