jquery $post应用 注册会员判断

 

1.mem_add.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn/conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员管理</title>
<link rel="stylesheet" type="text/css" href="css/news.css">
<script language="JavaScript" type="text/javascript" src="jquery-1.3.min.js"></script>
<script language="JavaScript" type="text/javascript" src="checkMem.js"></script>
</head>

<body>
<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
<form action="mem_save.asp" method="post" onSubmit="return checkMem()">
<tr>
    <td height="30" colspan="6" align="center" bgcolor="#f5f5f5">会员信息</td>
</tr>
<tr>
    <td width="11%" height="30" align="right" bgcolor="#FFFFFF">登录名:</td>
    <td colspan="3" bgcolor="#FFFFFF"><input class="form" id="MemName" maxlength="16" οnblur="startcheck(this.value);" name="MemName" οnkeyup="value=value.replace(/[^a-z0-9_]/g,'')" /><span id="CheckTxt">不可更改(只能用数字和字符)</span></td>
<script language="JavaScript" type="text/javascript">
function startcheck(MemName)
   {
  
   if (MemName!="")
   {
  
   var url="member.asp";
   $.post(url, {"MemName": escape(MemName) }, function (data){ if (data=="ok") {$("#CheckTxt").html("用户名可用!");} else{$("#CheckTxt").html("该用户已经被注册!");}})
   }
   }
</script>

    <td width="9%" align="right" bgcolor="#FFFFFF">真实姓名:</td>
    <td width="33%" bgcolor="#FFFFFF"><input class="form" id="RealName" maxlength="50"
                  name="RealName" /></td>
</tr>
<tr>
    <td height="30" align="right" bgcolor="#FFFFFF">性别:</td>
    <td width="15%" bgcolor="#FFFFFF"><input type="radio" checked="checked" value="男" name="Sex" />

<input type="radio" value="女" name="Sex" />
女</td>
    <td width="5%" bgcolor="#FFFFFF">等级:</td>
    <td width="27%" bgcolor="#FFFFFF">&nbsp;
<select name="Grade" id="Grade">
<option value="">--请选择--</option>
<%
set rs= Server.CreateObject("adodb.recordset")
rs.open "Select usertitle,GroupPic From Dv_UserGroups Where ParentGID=3 Order By MinArticle",conn,1,1
   if rs.bof and rs.eof then
   rs.close
   set rs=nothing
   else
   do while not rs.eof
%>

<option value="<%=rs("grouppic")%>"><%=rs("usertitle")%></option>
<%
rs.movenext
loop
rs.close
set rs=nothing
end if
%>
    </select>
</td>
    <td align="right" bgcolor="#FFFFFF">密码:</td>
    <td bgcolor="#FFFFFF"><input class="form" id="Password" type="text"
                  maxlength="16" name="Password" /></td>
</tr>

<tr>
    <td height="30" align="right" bgcolor="#FFFFFF">单位名称:</td>
    <td colspan="3" bgcolor="#FFFFFF"><input class="form" id="Company" maxlength="100" size="40"
                  name="Company" /></td>
    <td align="right" bgcolor="#FFFFFF">地址:</td>
    <td bgcolor="#FFFFFF"><input class="form" id="Address" maxlength="100" size="40"
                  name="Address" /></td>
</tr>
<tr>
    <td height="30" align="right" bgcolor="#FFFFFF">邮编:</td>
    <td colspan="3" bgcolor="#FFFFFF"><input class="form" id="ZipCode" maxlength="20" name="ZipCode" /></td>
    <td align="right" bgcolor="#FFFFFF">电话:</td>
    <td bgcolor="#FFFFFF"><input class="form" id="Telephone" maxlength="50"
                  name="Telephone" /></td>
</tr>
<tr>
    <td height="30" align="right" bgcolor="#FFFFFF">传真:</td>
    <td colspan="3" bgcolor="#FFFFFF"><input class="form" id="Fax" maxlength="50" name="Fax" /></td>
    <td align="right" bgcolor="#FFFFFF">移动电话:</td>
    <td bgcolor="#FFFFFF"><input class="form" id="Mobile" maxlength="50" name="Mobile" /></td>
</tr>
<tr>
    <td height="30" align="right" bgcolor="#FFFFFF">电子邮箱:</td>
    <td colspan="5" bgcolor="#FFFFFF"><input class="form" id="Email" maxlength="50"
                  name="Email" /></td>
    </tr>
<tr>
    <td height="30" colspan="6" align="center" bgcolor="#FFFFFF">&nbsp;<input name="提交" type="submit" value="确定" />
      <input name="button" type="reset" value="重置" /></td>
</tr>
</form>
</table>
</body>
</html>

2.member.asp

<!--#include file="../conn/conn.asp"-->
<%
Response.Charset="gb2312"
response.cachecontrol="no-cache"
response.addHeader "pragma","no-cache"
response.expires=-1
response.expiresAbsolute=now-1
dim MemName,sql,rs,newsType

MemName=trim(request("MemName"))
sql="select * from member where MemName='"&MemName&"'"

set rs=createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.close
set rs=nothing
response.Write"ok"
else
rs.close
set rs=nothing
response.Write"no"
end if

conn.close
set conn=nothing

%>
3.checkMem.js

// JavaScript Document
function checkMem()
{
if ($("#MemName").val()=="")
{
   alert("请填写登录名!");
   $("#MemName").focus();
   return false;
}
if ($("#MemName").val().length<=4||$("#MemName").val().length>=16)
{
   alert("登录名必须是4~16位!");
   $("#MemName").focus();
   return false;
}

if ($("#Grade").val()=="")
{
   alert("请选择等级!");
   $("#Grade").focus();
   return false;
}

if ($("#Password").val()=="")
{
   alert("请填写密码!");
   $("#Password").focus();
   return false;
}

if ($("#Password").val().length<=4||$("#Password").val().length>=16)
{
   alert("密码必须是4~16位!");
   $("#Password").focus();
   return false;
}


//if ($("#Password").val()!=$("#vPassword").val())
// {
//   alert("密码不一致!");
//   $("#vPassword").focus();
//   return false;
// }
//if ($("#Question").val()=="")
// {
//   alert("提示问题不能为空!");
//   $("#Question").focus();
//   return false;
// }
// if ($("#Answer").val()=="")
// {
//   alert("提示答案不能为空!");
//   $("#Answer").focus();
//   return false;
// }
if ($("#Email").val()=="")
{
   alert("请填写email!");
   $("#Email").focus();
   return false;
}
if (!Isyx($("#Email").val()))
{
   alert("请正确填写email!");
   $("#Email").focus();
   return false;
}



}

function Isyx(yx){
var reyx= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
return(reyx.test(yx));
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值