博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简单的jQuery检测注册用户名
阅读量:4447 次
发布时间:2019-06-07

本文共 1759 字,大约阅读时间需要 5 分钟。

test.html

view plaincopy to clipboardprint?

<html> 
<head> 
<title>表单验证</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">用户名:<input type="text" name="username" id="username" /><span id="msg1"></span></p> 
</form> 
</body> 
</html> 
<html>
<head>
<title>表单验证</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">用户名:<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("对不起,此用户名已注册。");  
        else 
            context.Response.Write("恭喜,当前用户名可以注册。");  
    }  
    public bool IsReusable  
    {  
        get 
        {  
            return false;  
        }  
    }  

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/gdjlc/archive/2009/11/20/4840261.aspx

转载于:https://www.cnblogs.com/xiachufeng/archive/2010/07/28/1786641.html

你可能感兴趣的文章
使用 Bootstrap Typeahead 组件
查看>>
第一次玩蛇,有点紧张。
查看>>
DAO层,Service层,Controller层、View层 的分工合作
查看>>
EF不能很好的支持DDD?估计是我们搞错了!
查看>>
用户登录安全框架shiro—用户的认证和授权(一)
查看>>
提取图片的文字
查看>>
Supports BorlandIDEServices
查看>>
SVM-支持向量机算法概述
查看>>
ios开发零食
查看>>
Coursera台大机器学习技法课程笔记01-linear hard SVM
查看>>
机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)
查看>>
Bag of Tricks for Image Classification with Convolutional Neural Networks论文笔记
查看>>
MACE环境搭建
查看>>
SD 信贷出口 备忘
查看>>
iOS正确的自定义View方式
查看>>
nginx修改php.ini生效:php-fpm重启与nginx加载配置文件
查看>>
ubuntu下基于sqlite3后台的php环境的搭建
查看>>
Qt 静态库与共享库(动态库)共享配置的一个小办法
查看>>
linux_cacti 配置之 安装snmp 服务
查看>>
201407-至今
查看>>