Ajax User Detection

Source: Internet
Author: User

The user experience brought about by Ajax is obvious to all. With the smallest application, let's try to implement it. Still use the hotheart ajaxrequest class. Start with ASP Ajax in another article.

The implementation result is as follows:

 

Let's not talk about other things. Look at the Code as follows:

Reg.html

<HTML>
<Head>
<Title> Ajax username detection </title>
<SCRIPT type = "text/JavaScript" src = "ajaxrequest. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
VaR Ajax = new ajaxrequest ();
Function regcheck (){
VaR uname = Document. getelementbyid ("user_name ");
Ajax. Get ("proc_user.asp? Action = regcheck & user_name = "+ uname. Value, usercheck );
}
Function usercheck (OBJ ){
Document. getelementbyid ("msg_user_name"). innerhtml = Unescape (obj. responsetext );
}
</SCRIPT>
</Head>
<Body>
Username: <input type = "text" name = "user_name" id = "user_name"/>
<Button onclick = "regcheck ();"> User Detection </button> <label id = "msg_user_name"> Note: Only admin and shaoyun users in the database </label>
</Body>
</Html>

Proc_user.asp

<! -- # Include file = "conn. asp" -->
<%
Dim action: action = trim (request. querystring ("action "))
Select case action
Case "regcheck"
Dim user_name, ret_string
User_name = trim (request. querystring ("user_name "))
If isreg (user_name) then
Ret_string = escape (user_name & "registered! Enter again! ")
Else
Ret_string = escape (user_name & "not registered! Available! ")
End if
Response. Write ret_string
End select

Function isreg (username)
Dim retval: retval = false
Openconn ("DB. mdb ")
Sqlstr = "select user_name from [user] Where user_name = '" & username &"'"
Call openrs (sqlstr, 1)
If not (Rs. bof and Rs. EOF) Then retval = true
Closers (): closeconn (): isreg = retval
End Function
%>

Note: The above instances require the IIS environment.

Attachment: ajax_usercheck_demo.rar

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.