Simple jQuery detection of registered usernames

Source: Internet
Author: User

Test.html

View plaincopy to clipboardprint?
<Html>
<Head>
<Title> Form Verification </title>
<Mce: script src = "jquery-1.3.2.min.js" mce_src = "jquery-1.3.2.min.js" type = "text/javascript"> </mce: script>
<Mce: script type = "text/javascript"> <! --
$ (Function (){
$ ("# Username"). blur (function (){
$. Get ("checkname. ashx ",{
Username: $ ("# username"). val ()
}, Function (data, textStatus ){
$ ("# Msg1" ).html(data).css ("color", "red ");
}
);
})
})
// --> </Mce: script>
</Head>
<Body>
<Form id = "form1">
<P id = "p1"> User Name: <input type = "text" name = "username" id = "username"/> <span id = "msg1"> </span> </p>
</Form>
</Body>
</Html>
<Html>
<Head>
<Title> Form Verification </title>
<Mce: script src = "jquery-1.3.2.min.js" mce_src = "jquery-1.3.2.min.js" type = "text/javascript"> </mce: script>
<Mce: script type = "text/javascript"> <! --
$ (Function (){
$ ("# Username"). blur (function (){
$. Get ("checkname. ashx ",{
Username: $ ("# username"). val ()
}, Function (data, textStatus ){
$ ("# Msg1" ).html(data).css ("color", "red ");
}
);
})
})
// --> </Mce: script>
</Head>
<Body>
<Form id = "form1">
<P id = "p1"> User Name: <input type = "text" name = "username" id = "username"/> <span id = "msg1"> </span> </p>
</Form>
</Body>
</Html>

Checkname. ashx

View plaincopy to clipboardprint?
<% @ WebHandler Language = "C #" Class = "checkname" %>
Using System;
Using System. Web;
Public class checkname: IHttpHandler
{
Public void ProcessRequest (HttpContext context)
{
Context. Response. ContentType = "text/plain ";
String username = context. Request. QueryString ["username"];
If (username = "gdjlc ")
Context. Response. Write ("sorry, this user name has been registered. ");
Else
Context. Response. Write ("Congratulations, you can register the current user name. ");
}
Public bool IsReusable
{
Get
{
Return false;
}
}
}

This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/gdjlc/archive/2009/11/20/4840261.aspx

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.