zoukankan      html  css  js  c++  java
  • jquery validate remote的用法

    JS:

    rules: {
                    Email: {
                        required: true,
                        email: true                    
                    },
                    Password: {
                        required: true,
                        remote: {
                            url: "/Users/Login",
                            type: "Post",
                            data: {
                                Email: function () { return $("#Email").val(); },
                                Password:function(){return $("#Password").val();}
                            }
                        }
                       
                    },
                    remember: {
                        required: false
                    }
                },

    cshtml:

    <form class="login-form" action="/Users/Login" method="post">
                <h3 class="form-title">Sign In</h3>
                <div class="alert alert-danger display-hide">
                    <button class="close" data-close="alert"></button>
                    <span>Email or Password is wrong!</span>
                </div>
                <div class="form-group">
                    <label class="control-label visible-ie8 visible-ie9">Email</label>
                    <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="Email" name="Email" id="Email">
                </div>
    
                <div class="form-group">
                    <label class="control-label visible-ie8 visible-ie9">Password</label>
                    <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="Password" id="Password"/>
                </div>
                <div class="form-actions">
                    <button type="submit" class="btn btn-success uppercase">Login</button>
                    <label class="rememberme check">
                        <input type="checkbox" name="remember" value="1" />Remember
                    </label>
                    <a href="javascript:;" id="forget-password" class="forget-password">Forgot Password?</a>
                </div>
                <div class="create-account">
                    <p>
                        <a href="javascript:;" id="register-btn" class="uppercase">Register an account</a>
                    </p>
                </div>
            </form>

    Controller:

    [HttpPost]
            public ActionResult Login(string Email,string Password)
            {
                string Msg = "";
                try
                {
                    string outmsg = "";
                    WeUser user = wbll.ULogin(Email, Password, out outmsg);
                    switch (outmsg)
                    {
                        case "-1": //没有此帐户或帐户错误
                            Msg = "false";
                            break;
                        case "error": //密码错误
                            Msg = "false";
                            break;
                        case "succeed":
                            Msg = "true";
                            return RedirectToAction("Index", "UsersCenter");                       
                        default:
                            break;
                    }
                }
                catch
                {
                    Msg = "false";
                }
                return Content(Msg);
            }

    当密码输入框失去焦点时出现如下提示:

    当点击“LOGIN"提交登录时会出现如下提示:

  • 相关阅读:
    怎样不重启设置字体边缘平滑立即生效! 以下注册表导入后不能立即生效。。
    Delphi下实现全屏快速找图找色 一、数据提取
    delphi2006语言新特性:Record类型高级用法
    delphi之模糊找图
    delphi之精确找图
    delphi2006语言新特性——类静态字段、类属性
    Delphi程序开启XP的ClearType显示效果
    delphi Createthread的线程传参数
    修改窗体非客户区大小更改窗体标题栏高度
    windows 匿名管道读取子进程输出
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/5011393.html
Copyright © 2011-2022 走看看