- <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();
-
- var params = ‘{browersType:"‘ + browers + ‘"}‘;
- $.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实现实时验证身份证信息是否已存在
原文:http://www.cnblogs.com/lschenblog/p/3946496.html