• 关于jquery登录的一些简单验证。


    获取值之后的判断  

      $(function () {
                $("#btlogin").click(function () {
                    var txtaccount = $("#txtaccount").val();//获取账号
                    var txtpassword = $("#txtpassword").val();//获取密码
                    if (txtaccount == "") {
                        $("#txtaccount").focus();
                        formMessage('登录账户不能为空', 'warning');
                        return false;
                    } else if (txtpassword == "") {
                        $("#txtpassword").focus();//使鼠标聚焦到密码框里面
                        formMessage('登录密码不能为空', 'warning');
                        return false;
                    } else {
                        formMessage('正在登录...', 'succeed');
                        window.setTimeout(function () {
                            var postData = {
                                Account: escape(txtaccount),//escape()对字符串编码
                                Password: escape($.md5(txtpassword))
    
                            }
                            getAjax('/Login/CheckLogin', postData, function (rs) {
                                if (parseInt(rs) == -1) {
                                    $("#txtaccount").focus();
                                    formMessage('登录账户不存在', 'error');
                                } else if (parseInt(rs) == 2) {
                                    $("#txtaccount").focus();
                                    formMessage('登录账户被系统锁定', 'error');
                                } else if (parseInt(rs) == 4) {
                                    $("#txtaccount").focus();
                                    $("#txtpassword").val("");
                                    formMessage('登录密码错误', 'error');
                                } else if (parseInt(rs) == 3) {
                                    formMessage('登录验证成功,正在跳转首页', 'succeed');
                                    setInterval(Load, 1000);
                                } else {
                                    alert(rs);
                                }
                            });
                        }, 500);
                    }
                })
            }

    登录成功后加载的界面:

    //登录加载
        function Load() {
            var Index = $.cookie('UItheme');
            if (Index) {
                window.location.href = '@Url.Content("~/Home/")' + Index;
            } else 
                window.location.href = '@Url.Content("”)';
            }
            return false;
    }

    formMessage:

    //提示信息
        function formMessage(msg, type) {
            $('.form-message').html('');//先清空数据
            $('.form-message').append('<div class="form-' + type + '-text">' + msg + '</div>');
        }
  • 相关阅读:
    二分图的部分关系
    二分图的部分关系
    日常训练赛 Problem C – Complete Naebbirac’s sequence
    日常训练赛 Problem C – Complete Naebbirac’s sequence
    J
    J
    Python strip()方法
    Python startswith()方法
    Python splitlines()方法
    Python split()方法
  • 原文地址:https://www.cnblogs.com/wfaceboss/p/7625456.html
Copyright © 2020-2023  润新知