Simple Ajax detects whether a user name registers functionality

Source: Internet
Author: User
The code is as follows Copy Code
<script type= "Text/javascript" >
function Showhint (str)
{
var xmlhttp;
if (str.length==0)
{
document.getElementById ("Txthint"). Innerhtml= "Sorry, your username cannot be empty";
Return
}
if (window. XMLHttpRequest)
{//code for ie7+, Firefox, Chrome, Opera, Safari
Xmlhttp=new XMLHttpRequest ();
}
Else
{//code for IE6, IE5
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
Xmlhttp.onreadystatechange=function ()
{
if (xmlhttp.readystate==4 && xmlhttp.status==200)
{
document.getElementById ("Txthint"). Innerhtml=xmlhttp.responsetext;
}
}
Xmlhttp.open ("Get", "check_name.aspx?q=" +str,true);
Xmlhttp.send ();
}<input id= "Tuname" runat= "onblur=" Showhint (this.value) "style=" font-size:20px; "class=" texbox15 "/>"
<asp:label id= "Txthint" runat= "Server" font-size= "13px" forecolor= "#33CC33" ></asp:Label>

Beginner Ajax Feel this effect is very practical

The code is as follows Copy Code

String qq = request.querystring["Q"]. ToString ();
String sql = "SELECT * from Cc_base_info where login_name= '" + QQ + "'";
CLASSDB db = new Classdb ();
SqlDataReader dr = Db.returndr (SQL);
if (Dr. Read ())
{
Response.Write ("<a style= ' color:red ' >" + "Sorry, the username already exists!" + "</a>");

}
Else
{
Response.Write ("<a style= ' Color:green ' >" + "Congratulations, the user name can be registered!" + "</a>");
}

Here is a simple to determine whether the user name is available for the operation, but also share with you. Take a note, by the way.

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.