• 用jquery写的校验用户名


    $(function(){
            $("input[name='username']").blur(function(){
                var uname = $(this).val();
                console.log(uname);
                console.log(uname=="");
                if (uname=="") {
                    $("#span1").html("用户名不能为空!");
                }else{
                    $.post(
                            "${pageContext.request.contextPath}/userAction_UserExists",
                            {"uname":uname},
                            function(data){
                                $("#span1").html(data);
                            },
                            'json'
                        );
                }
            });
        });

    后端java代码:

    private String uname;
        public String UserExists() throws IOException {
            log.info(uname);
            if ("admin".equals(uname)) {
                String s = "[{"info":"用户名不存在!"}]";
                String json = JSONArray.fromObject(s).toString();
                ServletActionContext.getResponse().getWriter().write(json);
            }else {
                
            }
            return null;
        }
    
        public void setUname(String uname) {
            this.uname = uname;
        }

    只给出了js代码和java代码,html代码太乱了不好意思往上贴

  • 相关阅读:
    分布式和集群
    c++ >>
    c++ ip地址相关
    c++ ip地址的操作 c版
    c++ 缺少动态库
    c++ dirname() basename()
    shell ulimit -n
    shell 进程查询相关的命令
    shell grep 高亮
    c++ swap 函数
  • 原文地址:https://www.cnblogs.com/fwnmmdzq/p/10362531.html
Copyright © 2020-2023  润新知