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>
  • 相关阅读:
    高盛、沃尔玛 题做出来还挂了的吐槽
    amazon师兄debrief
    到所有人家距离之和最短的中点 296. Best Meeting Point
    问问题没人回答的情况怎么办终于有解了
    找名人 277. Find the Celebrity
    数组生存游戏 289. Game of Life
    547. Number of Provinces 省份数量
    428. Serialize and Deserialize Nary Tree 序列化、反序列化n叉树
    alias别名简介和使用
    面试官:线程池执行过程中遇到异常会发生什么,怎样处理? Vincent
  • 原文地址:https://www.cnblogs.com/findw/p/2219645.html
Copyright © 2011-2022 走看看