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