AJAX+jQuery+ASP實現即時驗證身份證資訊是否已存在

來源:互聯網
上載者:User

標籤:style   os   io   java   ar   for   資料   art   cti   

  1. <span style="font-size:18px"><td height="25" align="right" class="style17">  
  2.         社會安全號碼  
  3.     :</td>  
  4.     <td height="25" align="left" class="style19">  
  5.         <input type="text" id="txtidNumber"  onblur="JudgeUserName()"  width="140px" />  
  6.           
  7. </td>  
  8.         <script type="text/javascript">  
  9.             function JudgeUserName() {  
  10.                //擷取頁面中的控制項的輸入的值  
  11.                 browers = +$("#txtidNumber").val();  
  12.                 //定義類型並將值傳遞給參數params  
  13.                 var params = ‘{browersType:"‘ + browers + ‘"}‘;  
  14.                 $.ajax({//調用ajax後台資料非同步方法呼叫  
  15.                     //提交的方式  
  16.                     type: "Post",  
  17.                     //資料的傳送頁面:要啟動介面的地址/介面的背景方法  
  18.                     url: "Add.aspx/SayHello",  
  19.                     contentType: "application/json; charset=utf-8",  
  20.                     data: params,  
  21.                     //傳到伺服器的參數類型  
  22.                     dataType: "json",  
  23.                      
  24.                     //重要的背景回呼函數(很重要)  
  25.                     success: function (data) {  
  26.                        //返回提示給介面效果  
  27.                         alert(data.d);  
  28.                                              
  29.                                             },  
  30.                   //出錯提示  
  31.                     error: function (err) {  
  32.                         alert(err);  
  33.                     }  
  34.                 });  
  35.             }  
  36. </span>  
  1. <span style="font-size:18px">[System.Web.Services.WebMethod()]  
  2.         public static string SayHello(string browersType)  
  3.         {  
  4.             //建立資料庫連接  
  5.              SqlConnection con = new SqlConnection("server=.;database=PersonnelFiles;uid=sa;pwd=123456;");  
  6.             //開啟串連  
  7.             con.Open();  
  8.             //查詢前台傳過來的資料資料庫中是否存在此資料  
  9.             SqlCommand cmd = new SqlCommand("select Count(*) from T_BasicInformation where idNumber=‘" + browersType + "‘", con);  
  10.             //返回有的條數  
  11.             int count = Convert.ToInt32(cmd.ExecuteScalar());  
  12.             //加以判斷  
  13.             if (count > 0)  
  14.             {  
  15.                 return "此人個人資訊已經存在,請修改原有資訊!";  
  16.   
  17.             }  
  18.             else  
  19.             {  
  20.                 return   "可以正確註冊";  
  21.             }  
  22.   
  23.         }  </span>  

AJAX+jQuery+ASP實現即時驗證身份證資訊是否已存在

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.