国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > AJAX > 正文

Ajax郵箱、用戶名唯一性驗證實例代碼

2024-09-01 08:30:55
字體:
來源:轉載
供稿:網友

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

 <script type="text/javascript">    $(function () {       $("#txtEmail").blur(function () {        $.ajax({          type: "post",          url: "reg.ashx?email=" + $.trim($("#txtEmail").val()) + "&d=" + (+new Date()),          success: function (data) {            var vCount = parseInt(data);            if (vCount == 0) {              alert("郵箱可以使用");            }            else {              alert("郵箱已經被占用");            }          }        });      });      $("#checkpwd").blur(function () {        return CheckPwd();      });    });    function CheckPwd()    {      var bCheck = true;      if ($.trim($("#pwd").val()) != $.trim($("#checkpwd").val()))      {        alert("兩次密碼輸入不一致");        bCheck = false;      }      return bCheck;    }  </script>

reg.ashx代碼:

using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace WebT1.Ti.html2{  /// <summary>  /// reg 的摘要說明  /// </summary>  public class reg : IHttpHandler  {    public void ProcessRequest(HttpContext context)    {      if (context.Request["email"] != null)      {        string strEmail = context.Request["email"];        List<UserModel> lstUser = DataService.GetUserList();        var v = lstUser.Where(p => p.Email == strEmail);        int iCount = 0;        if (v.Count() > 0)        {          iCount = 1;        }        context.Response.ContentType = "text/plain";        context.Response.Write(iCount.ToString());      }    }    public bool IsReusable    {      get      {        return false;      }    }  }  public class DataService  {    /// <summary>    /// 模擬已注冊用戶數據    /// </summary>    public static List<UserModel> GetUserList()    {      var list = new List<UserModel>();      list.Add(new UserModel() { Email = "t1@demo.com" });      list.Add(new UserModel() { Email = "t2@demo.com" });      list.Add(new UserModel() { Email = "t3@demo.com" });      list.Add(new UserModel() { Email = "t4@demo.com" });      list.Add(new UserModel() { Email = "t5@demo.com" });      return list;    }  }  public class UserModel  {    public string Email { get; set; }  }}

總結

以上所述是小編給大家介紹的Ajax郵箱、用戶名唯一性驗證實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大关县| 洛扎县| 游戏| 馆陶县| 石棉县| 夏邑县| 民县| 黎川县| 荔波县| 鸡泽县| 溧水县| 龙门县| 察哈| 于田县| 桂平市| 红河县| 清丰县| 石门县| 喜德县| 仪陇县| 龙门县| 长治县| 平昌县| 遵化市| 西安市| 长沙县| 肇源县| 嘉义市| 平远县| 舞阳县| 青州市| 裕民县| 桃园市| 都匀市| 庆云县| 五台县| 湄潭县| 额尔古纳市| 郑州市| 临湘市| 石渠县|