• 实用的注册表单验证代码


      1 <script language="javascript">      
      2 function IsDigit(cCheck)      
      3  {      
      4  return (('0'<=cCheck) && (cCheck<='9'));      
      5  }      
      6       
      7 function IsAlpha(cCheck)      
      8  {      
      9  return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))      
     10  }               
     11        
     12 function IsaNull(cCheck)           
     13  {           
     14  return(cCheck != " ")          
     15  }                                
     16        
     17 function checkform()      
     18 {  
     19   id = document.sform1.id.value;      
     20  if (id == "")      
     21   {      
     22   alert("请输入注册名");      
     23   document.sform1.id.focus();      
     24   return false;      
     25   }      
     26       
     27  for (nIndex=0; nIndex<id.length; nIndex++)      
     28   {      
     29   cCheck = id.charAt(nIndex);      
     30   if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))      
     31    {      
     32    alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");      
     33    document.sform1.id.focus();      
     34    return false;      
     35    }      
     36   }  
     37   chineseid = document.sform1.chineseid.value;      
     38  if (chineseid == "")      
     39   {      
     40   alert("请输入中文昵称");      
     41   document.sform1.chineseid.focus();      
     42   return false;      
     43   }     
     44  password = document.sform1.password.value;      
     45  if (password == "")      
     46   {      
     47   alert("请输入登陆密码");      
     48   document.sform1.password.focus();      
     49   return false;      
     50   }  
     51  password1 = document.sform1.password1.value;      
     52  if (password>password1)      
     53   { 
     54      alert("重复密码与登陆密码不相同");      
     55   document.sform1.password.focus();  
     56                                 document.sform1.password1.focus();      
     57   return false; 
     58   }   
     59 if (password<password1)      
     60   { 
     61      alert("重复密码与登陆密码不相同");      
     62   document.sform1.password.focus();  
     63                                 document.sform1.password1.focus();      
     64   return false; 
     65   }  
     66  if (document.sform1.email.value == "")      
     67   {      
     68   alert("请输入您的E-MAIL地址");      
     69   document.sform1.email.focus();      
     70   return false;      
     71   }      
     72        
     73  email=document.sform1.email.value;       
     74  emailerr=0      
     75  for (i=0; i<email.length; i++)      
     76   {      
     77   if ((email.charAt(i) == "@") & (email.length > 5))      
     78    {      
     79      emailerr=emailerr+1      
     80    }      
     81   }      
     82  if (emailerr != 1)      
     83   {      
     84   alert("请输入正确的E-MAIL地址");      
     85   document.sform1.email.focus();      
     86   return false;      
     87   }            
     88    
     89  if (document.sform1.checkask.value=="")  
     90   {  
     91    alert("密码提示问题不能为空");      
     92    document.sform1.checkask.focus();      
     93    return false;   
     94   }  
     95  if (document.sform1.checkans.value=="")  
     96   {  
     97    alert("您的密码提示问题答案不能为空");  
     98    document.sform1.checkans.focus();      
     99    return false;   
    100   }
    101  return true;      
    102       
    103 }  
    104 </script>
  • 相关阅读:
    blocking to nonblocking of Python
    hug -- Embrace the APIs of the future
    supplychain on blockchain
    xstate -- JavaScript state machines and statecharts
    计算PI -- 采用刘徽的割圆术方法
    Gunicorn
    AIOHTTP
    APScheduler
    prefect
    FastAPI
  • 原文地址:https://www.cnblogs.com/xiaoyunxiao/p/2431574.html
Copyright © 2020-2023  润新知