js

<% @Pagelanguage = " c# " Codebehind = " RegUser.aspx.cs " AutoEventWireup = " false " Inherits = " Enterprise.Web.RegUser " %>
<! DOCTYPEHTMLPUBLIC " -//W3C//DTDHTML4.0Transitional//EN " >
< html >
< head >
< title > 用户注册 </ title >
< metaname = " GENERATOR " Content = " MicrosoftVisualStudio.NET7.1 " >
< metaname = " CODE_LANGUAGE " Content = " C# " >
< metaname = " vs_defaultClientScript " content = " JavaScript " >
< metaname = " vs_targetSchema " content = " http://schemas.microsoft.com/intellisense/ie5 " >
< LINKrel = " stylesheet " type = " text/css " href = " /CSS/EnterpriseWebSite.css " >
< scriptsrc = " /js/CommonFunction.js " ></ script >
< script >
varreg
= {};
reg.userName
= '' ;
reg.password
= '' ;
reg.confirmPassword
= '' ;
reg.question
= '' ;
reg.answer
= '' ;
reg.url
= '' ;
reg.sex
= 1 ;
reg.email
= '' ;
reg.tel
= '' ;
reg.mobile
= '' ;
reg.qq
= '' ;
reg.address
= '' ;
reg.postalcode
= '' ;
reg.form
= null ;

functionbtnSubmit_onclick()
{
reg.form
= document.forms[ 0 ];
varcomFun
= new commonFunction();

if ( ! comFun.checkIsEmpty(reg.form))
{
return false ;
}

if (comFun.$getElementById( ' txtPassword ' ).value != comFun.$getElementById( ' txtConfirmPassword ' ).value)
{
alert(
' 两次密码输入不一致 ' );
comFun.$getElementById(
' txtConfirmPassword ' ).select();
return false ;
}

reg.userName
= comFun.$getElementById( ' txtUserName ' );
reg.password
= comFun.$getElementById( ' txtPassword ' );
reg.question
= comFun.$getElementById( ' txtQuestion ' );
reg.answer
= comFun.$getElementById( ' txtAnswer ' );
reg.url
= comFun.$getElementById( ' txtUrl ' );
reg.email
= comFun.$getElementById( ' txtEmail ' );
reg.tel
= comFun.$getElementById( ' txtTel ' );
reg.mobile
= comFun.$getElementById( ' txtMobile ' );
reg.qq
= comFun.$getElementById( ' txtQQ ' );
reg.address
= comFun.$getElementById( ' txtAddress ' );
reg.postalcode
= comFun.$getElementById( ' txtPostalcode ' );

vares
= comFun.$getElementsByName( ' sex ' );
vareL
= es.length;
for (vari = 0 ;i < eL;i ++ )
{
vare
= es[i];
if (e. checked )
{
reg.sex
= e.value;
break ;
}
}

RegUser.Reg(reg.userName.value,reg.password.value,reg.question.value,reg.answer.value,reg.url.value,reg.sex.value,reg.email.value,reg.tel.value,reg.mobile.value,reg.qq.value,reg.address.value,reg.postalcode.value,callback_Reg);
}

functioncallback_Reg(res)
{
varrv
= res.value;
if (rv)
{
alert(
' 注册成功! ' );
window.location.href
= ' /Default.aspx ' ;
}
else
{
alert(
' 有错误发生,注册失败!有可能是用户名或者域名被别人注册过了! ' );
}
}

// 检测用户名的域名是否被其它用户注册过了
functioncheckIsRegistered(obj,errorS,t)
{
varv
= obj.value;

varrv
= RegUser.CheckIsRegistered(v,t).value;
if (rv)
{
alert(errorS);
obj.select();
return false ;
}
}
</ script >
</ head >
< bodyMS_POSITIONING = " GridLayout " >
< formid = " Form1 " method = " post " runat = " server " >
< tablewidth = " 98% " border = " 0 " align = " center " cellpadding = " 3 " cellspacing = " 0 " >
< tr >
< tdwidth = " 16% " >< divalign = " right " > 用户名: </ div >
</ td >
< tdwidth = " 84% " >< inputtype = " text " id = " txtUserName " onblur = " checkIsRegistered(this,'该用户名已经被注册,请使用其它的!',1) " maxlength = " 15 " isRequired = " true " isValidate = " true " errorSForEmpty = " 用户名不能为空! " errorSForValidate = " 匹配出错!以字母开头,允许3-16字节,允许字母数字下划线以及许可的安全符号! " validatePattern = " /^[a-zA-Z][a-zA-Z0-9_$%]{2,15}$/ " title = " 用户名必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 密码: </ div >
</ td >
< td >< inputtype = " password " id = " txtPassword " maxlength = " 15 " isRequired = " true " isValidate = " true " errorSForEmpty = " 密码不能为空! " errorSForValidate = " 匹配出错!要求3-16字节,允许字母数字下划线以及许可的安全符号!! " validatePattern = " /^[a-zA-Z0-9_$%]{2,15}$/ " title = " 密码必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 确认密码: </ div >
</ td >
< td >< inputtype = " password " id = " txtConfirmPassword " isRequired = " true " errorSForEmpty = " 确认密码不能为空! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 密码提示问题: </ div >
</ td >
< td >< inputtype = " text " id = " txtQuestion " maxlength = " 50 " isRequired = " true " isValidate = " true " errorSForEmpty = " 密码提示问题没有填写! " errorSForValidate = " 长度必须在8-50个字之间且不得有空格! " validatePattern = " //S{8,50}/ " title = " 密码提示问题必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 密码问题答案: </ div >
</ td >
< td >< inputtype = " text " id = " txtAnswer " maxlength = " 50 " isRequired = " true " isValidate = " true " errorSForEmpty = " 密码问题答案没有填写! " errorSForValidate = " 长度必须在8-50个字之间且不得有空格! " validatePattern = " //S{8,50}/ " title = " 密码问题答案必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 站点Url: </ div >
</ td >
< td >< inputtype = " text " id = " txtUrl " onblur = " checkIsRegistered(this,'该Url已经被注册,请使用其它的!',2) " maxlength = " 20 " isRequired = " true " isValidate = " true " errorSForEmpty = " 站点Url不能为空! " errorSForValidate = " 站点Url格式不对! " validatePattern = " /^[a-zA-Z0-9]{1,20}$/ " title = " 站点Url必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 性别: </ div >
</ td >
< td >< inputtype = " radio " id = " boy " name = " sex " value = " 1 " checked > & nbsp; & nbsp; < inputtype = " radio " id = " girl " name = " sex " value = " 0 " > </ td >
</ tr >
< tr >
< td >< divalign = " right " > Email: </ div >
</ td >
< td >< inputtype = " text " id = " txtEmail " isValidate = " true " errorSForValidate = " Email格式不正确! " validatePattern = " /^.+/@(/[?)[a-zA-Z0-9/-/.]+/.([a-zA-Z]{2,3}|[0-9]{1,3})(/]?)$/ " ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 固定电话: </ div >
</ td >
< td >< inputtype = " text " id = " txtTel " isRequired = " true " isValidate = " true " errorSForEmpty = " 固定电话不能为空! " errorSForValidate = " 固定电话格式不对!请使用0592-5555555的格式! " validatePattern = " /^(/d{3}-|/d{4}-)?(/d{8}|/d{7})$/ " title = " 固定电话必须填写! " >< fontcolor = " #ff0000 " >*</ font ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 移动电话: </ div >
</ td >
< td >< inputtype = " text " id = " txtMobile " isValidate = " true " errorSForValidate = " 移动电话格式不正确! " validatePattern = " /^1/d{10}$/ " ></ td >
</ tr >
< tr >
< td >< divalign = " right " > QQ: </ div >
</ td >
< td >< inputtype = " text " id = " txtQQ " isValidate = " true " errorSForValidate = " QQ格式不正确! " validatePattern = " /^[1-9]*[1-9][0-9]*$/ " ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 住址: </ div >
</ td >
< td >< inputtype = " text " id = " txtAddress " ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 邮编: </ div >
</ td >
< td >< inputtype = " text " id = " txtPostalcode " maxlength = " 6 " isValidate = " true " errorSForValidate = " 邮编不正确! " validatePattern = " /^/d{6}/ " ></ td >
</ tr >
< tr >
< td >< divalign = " right " > 操作: </ div >
</ td >
< td >< inputtype = " button " value = " 注册 " id = " btnSubmit " onclick = " btnSubmit_onclick() " >& nbsp; & nbsp; < inputtype = " reset " value = " 重置 " ></ td >
</ tr >
</ table >
</ form >
</ body >
</ html >


在上面的代码中,有包含了一个CommonFunction.js文件,下面这是他的内容:

/* **********************************************************
*
*公共js函数
*
**********************************************************
*/
functioncommonFunction()
{
// checkvalueisnullorempty
this .checkIsEmpty = function(obj)
{
varflag
= true ;
for (vari = 0 ;i < obj.length;i ++ )
{
vare
= obj.item(i);
if (e.isRequired)
{
if (e.value == '' )
{
alert(e.errorSForEmpty);
e.focus();
flag
= false ;
break ;
}
}

if (e.isValidate)
{
if ( this .checkValidate(e) == false )
{
alert(e.errorSForValidate);
e.select();
e.focus();
flag
= false ;
break ;
}
}
}

return flag;
}

// checkvalueisvalidate
this .checkValidate = function(e)
{
varv
= e.value;
if (v != '' )
{
return this .checkReg(e.validatePattern,v);
}
}

// regexpvalidate
this .checkReg = function(pattern,value)
{
pattern
= pattern.substring( 1 ,pattern.length - 1 );
varreg
= new RegExp(pattern);
if ( ! reg.test(value))
{
return false ;
}
}

// returnanElementByidobjectforwhatid.
this .$getElementById = function(id)
{
vare
= document.getElementById(id);

if (e != ' undefined ' )
{
return e;
}

return ;
}

// returnanElementBynameobjectforwhatid.
this .$getElementsByName = function(id)
{
vare
= document.getElementsByName(id);

if (e != ' undefined ' )
{
return e;
}

return ;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值