校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > Ajax郵箱、用戶名唯一性驗證實例代碼

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

熱門標簽:外呼系統api對接 提高電話機器人接通率 大學校門地圖標注 荊州智能電銷機器人 福建微碼電話機器人 銷售電銷機器人詐騙 平涼高德地圖標注商戶要收費嗎 廣西智能外呼系統多少錢 地圖標注與公司業務關系

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

 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"];
        ListUserModel> 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 ListUserModel> GetUserList()
    {
      var list = new ListUserModel>();
      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郵箱、用戶名唯一性驗證實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

您可能感興趣的文章:
  • PHP+Ajax異步通訊實現用戶名郵箱驗證是否已注冊( 2種方法實現)
  • Ajax實時驗證用戶名/郵箱等是否已經存在的代碼打包

標簽:黔東 衡陽 內江 海南 婁底 德陽 樂山 邯鄲

巨人網絡通訊聲明:本文標題《Ajax郵箱、用戶名唯一性驗證實例代碼》,本文關鍵詞  Ajax,郵箱,用,戶名,唯一性,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Ajax郵箱、用戶名唯一性驗證實例代碼》相關的同類信息!
  • 本頁收集關于Ajax郵箱、用戶名唯一性驗證實例代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 渭源县| 昌乐县| 多伦县| 平度市| 寿光市| 九龙城区| 南岸区| 舒城县| 南城县| 萍乡市| 南和县| 宁津县| 恩平市| 涪陵区| 潢川县| 井冈山市| 通海县| 临潭县| 桦南县| 海城市| 惠东县| 天峻县| 新竹县| 克拉玛依市| 白河县| 昆明市| 巨鹿县| 定日县| 西昌市| 阜平县| 潼南县| 始兴县| 宜春市| 五峰| 东港市| 东乌| 沾益县| 公安县| 博客| 南宁市| 特克斯县|