欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Ajax如何實現(xiàn)郵箱、用戶名唯一性驗證

這篇文章將為大家詳細講解有關Ajax如何實現(xiàn)郵箱、用戶名唯一性驗證,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

成都創(chuàng)新互聯(lián)電話聯(lián)系:18980820575,為您提供成都網(wǎng)站建設網(wǎng)頁設計及定制高端網(wǎng)站建設服務,成都創(chuàng)新互聯(lián)網(wǎng)頁制作領域10年,包括除甲醛等多個方面擁有豐富的網(wǎng)站維護經(jīng)驗,選擇成都創(chuàng)新互聯(lián),為網(wǎng)站保駕護航!

具體代碼如下所示:

 <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("郵箱已經(jīng)被占用");
            }
          }
        });
      });
      $("#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>
    /// 模擬已注冊用戶數(shù)據(jù)
    /// </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如何實現(xiàn)郵箱、用戶名唯一性驗證”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

網(wǎng)站名稱:Ajax如何實現(xiàn)郵箱、用戶名唯一性驗證
本文地址:http://www.chinadenli.net/article32/jdhpsc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版搜索引擎優(yōu)化App開發(fā)建站公司網(wǎng)站營銷關鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管