码迷,mamicode.com
首页 > Web开发 > 详细

关于jquery忘记密码模块思路问题

时间:2016-08-19 09:49:19      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

首先是前台页面,input button 后台调用服务器端事件用onserverclick

但是有一个问题,那就是会刷新前台页面数据,所以把button放到updatepanel中便不会刷新

<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">//解决button 后台启动时间后前台页面刷新需要加updatepanel
        </asp:ScriptManager>
        <div class="info-title clearfix">
            <h6 class="l" id="title"></h6>
        </div>
        <div class="baseinfo-form ">

            <div class="baseinfo-form-row">
                <label for="" id="lblIdentity"></label>
                <input id="txtIdentity" type="text" class="baseinfo-form-input media " runat="server">
                <label id="IdentityError" class="pwdstyle" style="display: none"></label>
            </div>
            <div class="baseinfo-form-row">
                <div class="base_left">
                    <label for="" id="lblTel"></label>
                    <input type="text" class="baseinfo-form-input media" id="txtPhone" disabled="disabled" runat="server">
                </div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <input type="button" class="r btn-send" runat="server" id="btn_send" value="发送" onserverclick="btn_send_Click" disabled="disabled" />//iput button调用后台服务器事件用onserverclick
                    </ContentTemplate>
                </asp:UpdatePanel>


                <%--<asp:Button class="r btn-send" runat="server" ID="btn_send" Text="发 送" OnClick="btn_send_Click" Enabled="false" ></asp:Button>--%>
                <label id="PhoneError" class="pwdstyle" style="display: none"></label>
            </div>
            <div class="baseinfo-form-row " id="yzmstyle">
                <label for="">验证码:</label>
                <input type="text" class="baseinfo-form-input media" id="txtValidate" disabled="disabled" runat="server">
                <label id="ValidateError" class="pwdstyle" style="display: none"></label>

            </div>
            <div class="baseinfo-form-row">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <label for=""></label>

                        <input type="button" class="r btn-Next" runat="server" id="btn_Next" value="下一步" onserverclick="btn_Next_Click" disabled="disabled" />
                    </ContentTemplate>
                </asp:UpdatePanel>


            </div>

        </div>

    </form>

jquery部分代码:

这里用到Jquery利用ajax无刷新调用后台方法,一般用一般处理程序,这里我用了一个页面作为一般处理程序

<script type="text/javascript">
        $(document).ready(function () {
            var logint = ‘<%=logint%>‘;
            if (logint == 0) {
                $("#title").html("个人密码找回");
                $("#lblIdentity").text("身份证:");
                $("#lblTel").text("移动电话:");
            }
            else {
                $("#title").html("单位密码找回");
                $("#lblIdentity").text("机构代码:");
                $("#lblTel").text("单位电话:");
            }
            $("#txtIdentity").blur(function () {
                //验证身份证号
                if ($("#txtIdentity").val() == "") {
                    $("#IdentityError").css(‘display‘, ‘inline‘);
                    $("#IdentityError").html("<font color=‘red‘>*不能为空!</font>");
                }
                else {
                    validateIdentity();
                }

            });
        });

        function validateIdentity() {
            //验证身份证
            var logint = ‘<%=logint%>‘;
            var identity = $("#txtIdentity").val();
            var type2 = "yzid";
            var strurl = "Common/ValidateInfo.aspx?logint=" + logint + "&identity=" + identity + "&type2=" + type2;

            $.ajax({
                url: strurl,
                type: "post",
                datatype: "text",
                success: function (returnValue) {
                    if (returnValue == "idNo") {
                        $("#IdentityError").css(‘display‘, ‘inline‘);
                        if (logint == 0) {
                            $("#IdentityError").html("<font color=‘red‘>*身份错误!</font>");
                        }
                        else {
                            $("#IdentityError").html("<font color=‘red‘>*机构错误!</font>");
                        }

                        $("#txtPhone").attr("disabled", "disabled");

                    }
                    else {
                        $("#IdentityError").css(‘display‘, ‘none‘);
                        //$("#btn_send").css(‘background-color‘, ‘#ff7e00‘);
                        $("#txtPhone").removeAttr("disabled");
                        //$("#btn_send").removeAttr("disabled");
                    }
                }
            })
        }
</script>

在另一个页面的pageload中写方法,jquery通过ajax调用这个方法

 public string logint
        {//账户类型
            get
            {
                if (Request.QueryString["logint"] != null)
                {
                    return Request.QueryString["logint"].ToString();
                }
                else
                {
                    return "";
                }
            }
        }

        public string identity
        {//身份证号
            get
            {
                if (Request.QueryString["identity"] != null)
                {
                    return Request.QueryString["identity"].ToString();
                }
                else
                {
                    return "";
                }
            }
        }

 protected void Page_Load(object sender, EventArgs e)
        {
            B_PK_User b_user = new B_PK_User();
            M_PK_User m_user=new M_PK_User();
            M_PK_ValidateCode m_code = new M_PK_ValidateCode();
            B_PK_ValidateCode b_code=new B_PK_ValidateCode();
            B_PK_Unit b_unit = new B_PK_Unit();
            M_PK_Unit m_unit = new M_PK_Unit();
            string rr = "";
            if (logint == "0")
            {//个人
                if (type == "yzid")
                {//验证身份证
                    m_user = b_user.SelectByIdentity(identity);
                    if (m_user == null)
                    {
                        rr = "idNo";
                    }
                    else
                    {
                        rr = "idYes";
                    }
                }
               

            Response.Write(rr);//成功

            Response.End();
        }

  

 

关于jquery忘记密码模块思路问题

标签:

原文地址:http://www.cnblogs.com/edisoner/p/5786196.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!