国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
DoNet用Ajax實(shí)現(xiàn)對(duì)修改密碼時(shí)輸入數(shù)據(jù)合法性的驗(yàn)證
.前臺(tái)頁(yè)面(Default.aspx):

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="<head runat="server">
    <title>修改密碼</title>
    <script type="text/javascript" src="JS/jquery-1.4.2.min.js"></script><%--添加對(duì)JQuery類庫(kù)的引用--%>
    <script type="text/javascript">
var oldPwdPass=false;
var newPwdPass=false;
var newPwd;
function checkOldPwd(pwd)
{
   if(pwd==""||pwd==null)
   {
      document.getElementById("get_old_passwordMsg").innerHTML="舊密碼不能為空!";
      return false;
   }
   else if(validatePwd(pwd))
   {
      document.getElementById("get_old_passwordMsg").innerHTML="舊密碼只能是6-16位的字母或數(shù)字!";
      return false;
   }
   else
   {
 
      document.getElementById("get_old_passwordMsg").innerHTML="";
      //下面自動(dòng)調(diào)用引用的JQuery類庫(kù)
      $.ajax({
                 type:"get",
                
轉(zhuǎn)到一般處理程序
                 data:{"Pwd":pwd,"random":Math.random()},              
                 success:function(data)
                 {              
                     if(data=="true")
                     {
                        oldPwdPass=true;
                        return true;
                     }
                     else
                     {
                        document.getElementById("get_old_passwordMsg").innerHTML="舊密碼輸入錯(cuò)誤!";
                        document.getElementById("get_old_password").value="";
                        return false;
                     }      
                 }                    
         });
   }                 
}

function checkNewPwd(pwd)
{
   if(pwd==""||pwd==null)
   {
      document.getElementById("get_new_passwordMsg").innerHTML="新密碼不能為空!";
      return false;
   }
   else if(validatePwd(pwd))
   {
      document.getElementById("get_new_passwordMsg").innerHTML="新密碼只能是6-16位的字母或數(shù)字!";
      return false;
   }
   else
   {
      newPwd=pwd;
      document.getElementById("get_new_passwordMsg").innerHTML="";
      return true;
   }   
}

function checkConfirmNewPwd(pwd)
{
   if(pwd==""||pwd==null)
   {
      document.getElementById("confirm_new_passwordMsg").innerHTML="確認(rèn)新密碼不能為空!";
      return false;
   }
   else if(validatePwd(pwd))
   {
      document.getElementById("confirm_new_passwordMsg").innerHTML="確認(rèn)新密碼只能是6-16位的字母或數(shù)字!";
      return false;
   }
   else
   {
      document.getElementById("confirm_new_passwordMsg").innerHTML="";
      if(newPwd!=""&&newPwd!=null)
      {
         if(newPwd!=pwd)
         {
            document.getElementById("confirm_new_passwordMsg").innerHTML="確認(rèn)新密碼與新密碼不一致!";
            document.getElementById("confirm_new_password").value="";
            return false;
         }
         else
         {
            document.getElementById("confirm_new_passwordMsg").innerHTML="";
            newPwdPass=true;
            return true;
         }
      }
      else
      {
         document.getElementById("get_new_passwordMsg").innerHTML="新密碼不能為空!";
         return false;
      }
     
   }   
}

function validatePwd(pwd)
{
   regularPaw=/^[\dA-Za-z(
!@#$%&)]{6,16}$/;
   if(regularPaw.test(pwd)==false)
   {
      return true;
   }
   else
   {
      return false;
   }
}

function updateNewPwd()
{
    if(oldPwdPass&&newPwdPass)
    {
       oldPwdPass=false;
       newPwdPass=false;
       $.ajax({
                 type:"get",
                 轉(zhuǎn)到一般處理程序
                 data:{"NewPwd":newPwd,"random":Math.random()},              
                 success:function(data)
                 {              
                     if(data=="true")
                     {
                        document.getElementById("get_old_password").value="";
                        document.getElementById("get_new_password").value="";
                        document.getElementById("confirm_new_password").value="";
                        alert("密碼修改成功!");
                     }
                     else
                     {
                        document.getElementById("get_old_password").value="";
                        document.getElementById("get_new_password").value="";
                        document.getElementById("confirm_new_password").value="";
                        alert("密碼修改失敗,請(qǐng)重新修改!");
                     }      
                 }                    
         });
    }
    else
    {
       alert("請(qǐng)?zhí)顚?xiě)完整修改密碼所必需的信息!");
    }
    return false;
}

</script>
</head>
<body>
    <form id="formBody" runat="server">
    <div>
   
   <div>
   <div>
     <b id="psnB1"></b><h3>修改密碼:</h3>
   </div> 
   <div class="ln-thin ln-c-mid"></div>
   <div style="height:1px; background-color:White"></div> 
    <table id="psnB1Table">  
     <tbody>  
       <tr>
         <th><label for="get_cust_name">您的會(huì)員登錄名是:</label></th>
         <td>
           <asp:Label ID="get_cust_name" runat="server" Text="Label" Font-Bold="True"></asp:Label>                   
         </td>                       
       </tr>                          
       <tr>
         <th><label for="get_old_password">舊密碼:</label></th>
         <td>
           <input id="get_old_password" type="password" onblur="checkOldPwd(this.value);" CssClass="required oldpawcl"/> <span style="color:Red; font-size:14px">*</span>
           <label id="get_old_passwordMsg"  class="errorMsg"></label>
         </td>
       </tr>
       <tr>
         <th><label for="get_new_password">新密碼:</label></th>
         <td>
           <input id="get_new_password" type="password" onblur="checkNewPwd(this.value);" CssClass="required newpawcl"/> <span style="color:Red; font-size:14px">*</span>
           <label id="get_new_passwordMsg" class="errorMsg"></label>
         </td>
       </tr>
       <tr>
         <th><label for="confirm_new_password">確認(rèn)新密碼:</label></th>
         <td>
           <input id="confirm_new_password" type="password" onblur="checkConfirmNewPwd(this.value);" CssClass="required cfnewpawcl"/> <span style="color:Red; font-size:14px">*</span>
           <label id="confirm_new_passwordMsg" class="errorMsg"></label>
         </td>
       </tr>
         
     </tbody>              
    </table>      
    </div>
    <div style="margin-bottom:-1px">
      <div class="ln-thin ln-c-mid"></div>  
      <div style="height:1px; background-color:White"></div>                
      <div id="psnTable4"></div>               
    </div>
    <table>                   
      <tbody>                       
      <tr>                           
       <th>
            </th>                           
       <td>
         <asp:Button ID="Finish" CssClass="Button" runat="server" Text="修 改" OnClientClick="javascript:return updateNewPwd();" />
       </td>                       
      </tr>                   
      </tbody>
      </table>
   
    </div>
    </form>
</body>
</html>

 


2.后臺(tái)代碼頁(yè)(Default.aspx.cs):

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["UserId"] = "001";
            Session["UserName"] = "HEHE";
        }
        get_cust_name.Text = Session["UserName"].ToString();//獲取當(dāng)前登錄用戶的Session中的UserName
    }

}

 


3.一般處理程序1(CheckPwd.ashx):

<%@ WebHandler Language="C#" Class="CheckPwd" %>

using System;
using System.Web;

public class CheckPwd : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string pwd = context.Request["Pwd"];

        string userId = context.Session["UserId"].ToString();
        string dbPwd = "123456";//演示密碼
               
        //string dbPwd=UpdatePasswordService.GetDbPwd(userId);//自己寫(xiě)的類中的方法,從數(shù)據(jù)庫(kù)中取出密碼。
        if (pwd == dbPwd)
        {
            context.Response.Write("true");
        }
        else
        {
            context.Response.Write("false");
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

 


4.一般處理程序2(UpdatePwd.ashx):

<%@ WebHandler Language="C#" Class="UpdatePwd" %>

using System;
using System.Web;

public class UpdatePwd : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string newPwd = context.Request["NewPwd"];
        string userId = context.Session["UserId"].ToString();
        bool result = true;//演示結(jié)果
        //bool result = UpdatePasswordService.UpdatePwd(userId, encryptPwd);//自己寫(xiě)的類中的方法,更新密碼并返回是否成功。
        if (result)
        {
            context.Response.Write("true");
        }
        else
        {
            context.Response.Write("false");
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
用google查密碼
js 為label標(biāo)簽和div標(biāo)簽賦值的方法
釘釘免登陸前端操作詳解
Ajax異步檢查用戶名是否存在
JavaScript 開(kāi)發(fā)規(guī)范要求
身份證函數(shù) 查看身份證地區(qū)信息-編程實(shí)例-eNet網(wǎng)絡(luò)學(xué)院-中國(guó)最權(quán)威的電腦教程軟件資訊網(wǎng)...
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服