posts - 84,  comments - 264,  trackbacks - 0

中华网BLOG注册页面检查代码

<!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" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-CN" />
<title>中华网博客---注册</title>

<script>
function checkEmail (str) {
  //alert(str);
  isEmail1=/^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
  isEmail2=/^.*@[^_]*$/;
  //alert(isEmail1.test(str)&&isEmail2.test(str));
  return (isEmail1.test(str)&&isEmail2.test(str));
}
function IsDigit(cCheck)     
 {     
 return (('0'<=cCheck) && (cCheck<='9'));     
 }     
     
function IsAlpha(cCheck)     
 {     
 return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))     
 }              
      
function IsaNull(cCheck)          
 {          
 return(cCheck != " ")         
 }        
 
function checkform(){
 //alert(document.bloguserForm.username.value);
 if (document.bloguserForm.username.value == ""){     
    alert("请输入注册名");     
    document.bloguserForm.username.focus();     
    return false;     
   }
   
   if(document.bloguserForm.username.value.length>20 || document.bloguserForm.username.value.length<6){
    alert("用户名为6到12个字母或数字");
    document.bloguserForm.username.focus();
    return false;
   }
   
   for (nIndex=0; nIndex<document.bloguserForm.username.value.length; nIndex++){
  cCheck = document.bloguserForm.username.value.charAt(nIndex);     
    if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')){     
      alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");     
      document.bloguserForm.username.focus();     
      return false;     
     }     
   }
   if (document.bloguserForm.password.value == ""){
    alert("请输入注册密码");     
    document.bloguserForm.password.focus();     
    return false;     
   }
   if(document.bloguserForm.password.value.length < 6 || document.bloguserForm.password.length >20){
    alert("密码长度在6--12位之间!");
    document.bloguserForm.password.focus();
    return false;
   }
   if(document.bloguserForm.password.value!=document.bloguserForm.password1.value){
    alert("密码不匹配!");
    document.bloguserForm.password.focus();
    return false;
   }
   if(document.bloguserForm.question.value == ""){
    alert("请输入密码问题!");
    document.bloguserForm.question.focus();
    return false;
   }
   if(document.bloguserForm.answer.value == ""){
    alert("请输入密码回答!");
    document.bloguserForm.answer.focus();
    return false;
   }
   if(!checkEmail(document.bloguserForm.mailbox.value)){
  alert('邮箱地址错误!');
  document.bloguserForm.mailbox.focus();
  return false;
 }
   if(!checkEmail(document.bloguserForm.mailbox.value)){
  alert('邮箱地址错误!');
  document.bloguserForm.mailbox.focus();
  return false;
 }
 document.bloguserForm.submit();
 return true;  
}


</script>

<link href="/form/css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<br />
<table width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
 <tr><td>
  
  
  
  
  
  
 </td></tr>
  <tr>
    <td height="31"><table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="35" height="30"><img src="/form/images/icon_greenball.jpg" width="23" height="21" /></td>
          <td class="tit_blue18">填写注册资料</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="3" background="/form/images/bg_line.gif"></td>
  </tr>
  <tr>
    <td height="8"></td>
  </tr>
</table>
<table width="90%" border="0" cellpadding="0" cellspacing="0" background="/form/images/bor_fillet05.gif" align="center">
  <tr>
    <td><img src="/form/images/bor_fillet01.gif" width="6" height="6" /></td>
    <td><img name="" src="" width="1" height="1" alt="" /></td>
    <td align="right"><img src="/form/images/bor_fillet02.gif" width="6" height="6" /></td>
  </tr>
</table>
<table width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="6" background="/form/images/bor_fillet06.gif"><img name="" src="" width="1" height="1" alt="" /></td>
    <td><table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" class="bor_btm txt_black">
 <form name="bloguserForm" method="post" action="/bloguser.do">
      <tr>
        <td width="3%"><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td width="13%">注册用户名:
        </td>
        <td width="27%"><input type="text" name="username" value=""></td>
        <td width="57%"><span class="txt_red">*用户名为6-12个字母或数字</span></td>
      </tr>
      <tr>
        <td><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td>注册用密码:</td>
        <td><input type="password" name="password" value=""></td>
        <td><span class="txt_red">密码为6-12个字母,密码区分大小写</span></td>
      </tr>
      <tr>
        <td><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td>确认密码:</td>
        <td><input type="password" name="password1" value=""></td>
        <td><span class="txt_red">*</span> </td>
      </tr>
      <tr>
        <td><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td>密码问题:</td>
        <td><input type="text" name="question" value=""></td>
        <td><span class="txt_red">*</span> </td>
      </tr>
      <tr>
        <td><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td>密码回答:</td>
        <td> <input type="text" name="answer" value=""></td>
        <td><span class="txt_red">*</span> </td>
      </tr>
      <tr>
        <td><img src="/form/images/icon_arrow.gif" width="9" height="9" /></td>
        <td>Email地址:</td>
        <td><input type="text" name="mailbox" value=""></td>
        <td><span class="txt_red">*</span> </td>
      </tr>
    <tr>
        <td colspan="4" align="center">&nbsp;
        <input type="image" name="imageField" src="/form/images/btn_submit.gif" onclick="return checkform();">
          </td>
        </tr>
   </form>
    </table>
    </td>
    <td width="6" background="/form/images/bor_fillet07.gif"><img name="" src="" width="1" height="1" alt="" /></td>
  </tr>
</table>
<table width="90%" border="0" cellpadding="0" cellspacing="0" background="/form/images/bor_fillet08.gif" align="center">
  <tr>
    <td><img src="/form/images/bor_fillet03.gif" width="6" height="6" /></td>
    <td><img name="" src="" width="1" height="1" alt="" /></td>
    <td align="right"><img src="/form/images/bor_fillet04.gif" width="6" height="6" /></td>
  </tr>
</table>
</body>
</html>

posted on 2005-09-29 16:19 wf 阅读(4591) 评论(2)  编辑 收藏 引用 所属分类: Published

FeedBack:
# re: 一个注册页面检查代码-JAVASCRIPT
2007-12-12 15:20 | coolray
感谢作者,代码写得很好!  回复  更多评论
  
# re: 一个注册页面检查代码-JAVASCRIPT
2010-03-04 16:24 | tlw
谢谢分享  回复  更多评论
  
只有注册用户登录后才能发表评论。
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

        欢迎来到我的BLOG~~~

        之前存放FLASH和音乐的地方down掉了,随便链个歌先听听吧~~~
免费的东西真不保险啊~~

听到首英文歌,挺好听的,放上来。。God is a girl。。far away from home

换了新歌All Out of Love

经推荐换个the power of dream~

换个歌I believe in love

今晚,我感觉离你很近---又换歌了

That place in your heart~~

I'm all about you~08317

always and forever~

Acros the universe

常用链接

留言簿(14)

随笔分类

随笔档案

文章分类

文章档案

相册

friend

study

  • Jacky26℃
  • 很全的计算机水平考试资料
  • topboyleo
  • a lot of English stuff like Action English......

最新评论

阅读排行榜

评论排行榜