zoukankan      html  css  js  c++  java
  • jQuery Validate表单验证帐号是否存在

    jQuery Validate验证部分

    //验证表单
    function validform() {
        return $("#form").validate({
            rules: {
                LoginName: {
                    required: true,
                    remote: {
                       url: "/AppWorker/LoginNameIsExist",     //后台处理程序
                       type: "post",               //数据发送方式
                       dataType: "json",           //接受数据格式    (一定是json 数据)
                       data: {                     //要传递的数据
                             name: function () {
                                return $("#Name").val();
                             }
                        },
                        dataType: "html",
                        dataFilter: function (data, type) {
                            if (data != "True")
                                return true;
                           else
                                return false;
                       }
                   }
    
                },
    
            },
            messages: {
                LoginName: {
                    required: "必须填写登录帐号",
                    remote: "帐号已经存在"
                }
              
            }
        });
    }
    

      Cotroller控制器部分

           /// <summary>
            /// 验证登录帐号是否被占用
            /// </summary>
            /// <returns></returns>
            [LoginActionFilter]
            public bool LoginNameIsExist()
            {
                string name = Request["name"].ToString();
                var obj = studentBLL.GetAll().FirstOrDefault(p => p.LoginName == name);
                return obj != null;//无结果返回false,有结果返回true
            }
    

      BLL部分

       public List<Student> GetAll()
            {
                var mql = StudentSet.SelectAll().Where(StudentSet.isLock.NotEqual(1));
                List<Student> list = studentDAL.GetEntities(mql);
                return list;
                //throw new NotImplementedException();
            }
    

      

  • 相关阅读:
    python中json.dumps()和json.dump() 以及 json.loads()和json.load()的区分
    Python的函数
    Python的Set容器
    Python的Dict容器
    Python的tuple容器
    Python的List容器
    python 的控制流程
    Python 数据类型
    k8s-Pod调度策略
    K8s创建pod yaml文件详解
  • 原文地址:https://www.cnblogs.com/lemonmoney/p/6878772.html
Copyright © 2011-2022 走看看