Email Ajax Transfer Data deduplication and non-null judgments

Source: Internet
Author: User

Front desk:

<TD class= "IN-CTT" width= "35%" ><input type= "text" name= "email" id= "email" required= "required"/><div ID = "Content" ></div>

Ajax:

$ (document). Ready (function () {

$ ("#email"). blur (function () {
$ ("#email"). CSS ("Background-color", "#D6D6FF");
$.ajax ({type: "post", url: "check_email.do", data:{' email ': $ ("#email"). Val ()},
Success:function (data) {

if (data==2) {
$ ("#content"). HTML ("<p> mailbox already exists </p>");
$ (". Btn"). attr ("Disabled", true);
}
if (data==1)
{
$ ("#content"). HTML ("<p></p>");
$ (". Btn"). attr ("disabled", false);
}
if (data==13)
{
$ ("#content"). HTML ("<p> mailbox cannot be empty </p>");
$ (". Btn"). attr ("Disabled", true);
}
}
});
});
});

Background data processing:

@RequestMapping ("Check_email.do")
public void Checkemail (HttpServletRequest request, httpservletresponse response) throws IOException {
PrintWriter out= Response.getwriter ();
String email= request.getparameter ("email");
Check if the database has duplicate names
Boolean exist = service.emailexist (email);
if (!exist) {
Servlets.writehtml (Response, "1");
} else {
Servlets.writehtml (Response, "2");
}
if (Stringutils.isblank (email))
Servlets.writehtml (Response, "3");
Out.close ();
/*if (Stringutils.isblank (email)) {
Servlets.writehtml (response, "false");
Return
}
if (stringutils.equals (email, original)) {
Servlets.writehtml (Response, "true");
Return
}
Check if the database has duplicate names
Boolean exist = service.emailexist (email);
if (!exist) {
Servlets.writehtml (Response, "true");
} else {
Servlets.writehtml (response, "false");
}*/
}

Yuan Sheng Backstage:

protected void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
Response.setcontenttype ("Text/html:charset=utf-8");
Response.setcharacterencoding ("Utf-8");
PrintWriter out= Response.getwriter ();
Request.setcharacterencoding ("Utf-8");
String username= request.getparameter ("username");
String password= request.getparameter ("password");

if (Username.equals ("Hong Fan"))
{
/*out.println ("<p>" +username+ "</p>"); */
Out.println ("1");

/*out.println ("<p>" +password+ "</p>");
Out.println ("<p>" + "User name accurate" + "</p>"); */

}else{
Out.print (username);
Out.print ("User name or password error");
}
Out.close ();



}

jquery Check textarea required

<script type= "Text/javascript" >
$ ("#sub1)." Click (function () {
var text1=$ ("#text1"). Val ();

if (text1== "") {

Alert ("Cannot be empty!");

$ ("#text1"). Select ();

$ ("#text1"). focus ();

}else{
$ ("#form1"). Submit ();
}

})
</script>

<body>
<form id= "Form1" method= "Post" action= "" >
<input type=text id= "Text1"/>
<input type= "Submit" id= "Sub1" value= "Commit" >
</form>
</body>

Email Ajax Transfer Data deduplication and non-null judgments

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.