zoukankan      html  css  js  c++  java
  • PHPChina表单验证

    <script language="javascript">
    function check() {    
    var name = document.form1.name.value,
    tel 
    = document.form1.phone.value,    
    age 
    = document.form1.age.value,    
    qq 
    = document.form1.qq.value,
    email 
    = document.form1.mail.value;    
        
    if(name=="") {    
            alert(
    "姓名为必填!");    
            document.form1.name.focus();
            
    return false;    
        }
        
    if (name.replace(/[^\x00-\xff]/g, "**").length > 8 || name.replace(/[^\x00-\xff]/g, "**").length <4 ){        
            alert(
    "请认真填写您的姓名!");    
            document.form1.name.focus();
            
    return false;    
        }    
        
    if(age=='') {
            alert(
    "请填写年龄");
            document.form1.age.focus();    
            
    return false;    
        }
        
    if(isNaN(age) || age>40 || age<10) {
            alert(
    "请认真填写年龄");
            document.form1.age.focus();    
            
    return false;    
        }    
        
    if(tel==""){    
            alert(
    "联系方式为必填!");    
            document.form1.phone.focus();
            
    return false;    
        }    
        
    if (isNaN(tel) || tel.replace(/[^\x00-\xff]/g, "**").length > 18 || tel.replace(/[^\x00-\xff]/g, "**").length<8 ) {    
            alert(
    "请认真填写联系方式!");
            document.form1.phone.focus();
            
    return false;
        }
        
    if(qq == '') {
            alert(
    "请填写QQ号码");
            document.form1.qq.focus();
            
    return false;
        }
        
    if(isNaN(qq) || qq.replace(/[^\x00-\xff]/g, "**").length > 11 || qq.replace(/[^\x00-\xff]/g, "**").length<5  ) {
            alert(
    "请输入合法QQ号码");
            document.form1.qq.focus();
            
    return false;
        }
            
    return true;
    }
    function war() {
        alert (
    "该功能已关闭开放!");
    }
    </script>
  • 相关阅读:
    H3C日志文件读取
    sql2000 转sql2008
    常用sql大全
    安装linux后,重新装windows,修复mbr引导
    SQL Server推荐使用 SET 而不是 SELECT 对变量进行赋值
    ORCLE 截取固定字符
    又是一个无聊的周未
    转一个无聊的爱情故事:如果有个女生为你哭
    Windows Mobile 6 SDK
    扩展FCKeditor
  • 原文地址:https://www.cnblogs.com/findw/p/2219645.html
Copyright © 2011-2022 走看看