Javascript and jquery implement user login verification respectively. javascriptjquery

Source: Internet
Author: User

Javascript and jquery implement user login verification respectively. javascriptjquery

In the previous article.

1. Key Code implemented using jquery ajax

The implementation is as follows:

/* Jquery implementation $ (document ). ready (function () {$ ("# account "). blur (function (event) {$. ajax ({type: "GET", url: "checkAccount. php? Account = "+ $ (" # account "). val (), dataTypes: "text", success: function (msg) {$ ("# accountStatus" ).html (msg) ;}, error: function (jqXHR) {alert ("Account Error! ") },}) ;}); $ (" # Password "). blur (function (event) {$. ajax ({type: "GET", url: "checkPassword. php? ", DataTypes:" text ", data:" account = "+ $ (" # account "). val () + "& password =" + $ ("# password "). val (), success: function (msg) {$ ("# passwordStatus" ).html (msg) ;}, error: function (jqXHR) {alert ("password query error! ")},});});});*/

II. Key to javascript implementationCode

The implementation is as follows:

// Javascript implements function checkAccount () {var xmlhttp; var name = document. getElementById ("account "). value; if (window. XMLHttpRequest) xmlhttp = new XMLHttpRequest (); else xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP "); xmlhttp. open ("GET", "checkAccount. php? Account = "+ name, true); xmlhttp. send (); xmlhttp. onreadystatechange = function () {if (xmlhttp. readyState = 4 & xmlhttp. status = 200) document. getElementById ("accountStatus "). innerHTML = xmlhttp. responseText ;}} function checkPassword () {var xmlhttp; var name = document. getElementById ("account "). value; var pw = document. getElementById ("password "). value; if (window. XMLHttpRequest) xmlhttp = new XMLHttpRequest (); Else xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP"); xmlhttp. open ("GET", "checkPassword. php? Account = "+ name +" & password = "+ pw, true); xmlhttp. send (); xmlhttp. onreadystatechange = function () {if (xmlhttp. readyState = 4 & xmlhttp. status = 200) document. getElementById ("passwordStatus "). innerHTML = xmlhttp. responseText ;}}

The mysql and database sections are the same as those in the previous blog. The running results are as follows:

The above is all the content of this article, hoping to help you learn.

Related Article

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.