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