jsp注册页面,Ajax实现验证用户名是否存在,密码是否一致,当不存在时,注册按钮变成灰色。...

register.jsp页面信息

<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    </span><span style="font-family:'AR PL UKai CN';">注册页面</span><span style="color:#e8bf6a;">
    


欢迎来到注册页面


action="/registerServlet" method="post"> 账号:type="text" name="username" id="username" οnblur="send()"/> id="Username_Error_Massage">
密码:type="password" name="password" id="password01"/>
重复密码:type="password" name="password_repeat" id="password02" οnblur="inspect_password()"/> id="div_password">
邮箱:type="email" name="email"/>
type="submit" value="提交" name="register"/>   registerServlet的代码如下:
package Servlet;

import javax.management.Query;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by user on 17-7-20.
 * This Servlet suppport register page.
 */
@WebServlet(name = "registerServlet",value = "/registerServlet")
public class registerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        
        if (username.equals("test")) {  //单纯测试,不进行连接数据库,,相同返回true
            response.getWriter().print(true);
        } else {        //不同返回false;
            response.getWriter().print(false);
        }
    }
}
 
最后结果如下:

转载于:https://www.cnblogs.com/guodao/p/9702481.html

你可能感兴趣的:(java,数据库,javascript,ViewUI)