Ajax+jquery+asp enables real-time verification of identity card information already exists

Source: Internet
Author: User

  1. <span style="font-size:18px" ><td height= "" align= "right" class="Style17" >
  2. ID number
  3. :</td>
  4. <TD height="align=" "left" class="Style19" >
  5. <input type="text" id="Txtidnumber" onblur= "Judgeusername()" Width="140px"/> /c0>
  6. </td>
  7. <script type="Text/javascript" >
  8. function Judgeusername () {
  9. //Gets the input value of the control in the page
  10. Browers = +$ ("#txtidNumber"). Val ();
  11. //define the type and pass the value to the parameter params
  12. var params = ' {browerstype: ' + browers + ' "} ';
  13. $.ajax ({//Invoke Ajax Backend data async method
  14. //How to submit
  15. Type: "Post",
  16. //Data transfer page: To start the interface of the address/interface of the background method
  17. URL: "Add.aspx/sayhello",
  18. ContentType: "Application/json; Charset=utf-8 ",
  19. Data:params,
  20. parameter types that are passed to the server
  21. DataType: "JSON",
  22. //Important back-end callback function (very important)
  23. Success: function (data) {
  24. //Return prompt to interface effect
  25. alert (DATA.D);
  26. },
  27. //Error alert
  28. Error: function (err) {
  29. alert (ERR);
  30. }
  31. });
  32. }
  33. </span>
  1. <span style="font-size:18px" >[system.web.services.webmethod ()]
  2. public static string SayHello (string browerstype)
  3. {
  4. //Create a database connection
  5. SqlConnection con = new SqlConnection ("server=.; database=personnelfiles;uid=sa;pwd=123456; ");
  6. //Open Connection
  7. Con. Open ();
  8. //Query whether this data exists in the data database sent by the foreground
  9. SqlCommand cmd = new SqlCommand ("Select Count (*) from t_basicinformation where idnumber= '" + browerstype + "'"  , con);
  10. //Return some number of bars
  11. int count = Convert.ToInt32 (cmd).  ExecuteScalar ());
  12. //To be judged
  13. if (Count > 0)
  14. {
  15. return "This person's personal information already exists, please modify the original information!"  ";
  16. }
  17. Else
  18. {
  19. return "can be registered correctly";
  20. }
  21. } </span>

Ajax+jquery+asp enables real-time verification of identity card information already exists

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.