佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Ajax郵箱、用戶名唯一性驗(yàn)證實(shí)例代碼

Ajax郵箱、用戶名唯一性驗(yàn)證實(shí)例代碼

熱門標(biāo)簽:Linux服務(wù)器 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 服務(wù)器配置 團(tuán)購(gòu)網(wǎng)站 銀行業(yè)務(wù) Mysql連接數(shù)設(shè)置 阿里云 電子圍欄

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

 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 的摘要說(shuō)明
  /// /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>
    /// 模擬已注冊(cè)用戶數(shù)據(jù)
    /// /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; }
  }
}

總結(jié)

以上所述是小編給大家介紹的Ajax郵箱、用戶名唯一性驗(yàn)證實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

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

標(biāo)簽:大理 蚌埠 衡水 江蘇 衢州 萍鄉(xiāng) 棗莊 廣元

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Ajax郵箱、用戶名唯一性驗(yàn)證實(shí)例代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    留坝县| 永兴县| 如皋市| 开江县| 黄梅县| 祁阳县| 许昌县| 固始县| 藁城市| 佛学| 南丰县| 凉山| 高淳县| 昭通市| 任丘市| 西充县| 万山特区| 格尔木市| 峨边| 大厂| 互助| 岳西县| 集贤县| 绥滨县| 云和县| 舟山市| 壶关县| 麻栗坡县| 汉川市| 江口县| 新蔡县| 准格尔旗| 嘉善县| 黎城县| 忻城县| 灵丘县| 曲靖市| 调兵山市| 吉首市| 金阳县| 开江县|