JS 验证

  1. <script language="JavaScript">  
  2. function Check(){  
  3.     var errorinfo = "";  
  4.     var isFocus = true;   
  5.     var groupUserName = document.getElementsByName("Custom.groupUserName")[0];  
  6.     if (groupUserName.value == ""){  
  7.         errorinfo += "机构客户名称为必填项,请输入!/n";  
  8.         if(isFocus){  
  9.                     groupUserName.focus();  
  10.                     isFocus = false;  
  11.         }                     
  12.     }  
  13.     var enterpriseAddress = document.getElementsByName("Custom.enterpriseAddress")[0];  
  14.     if (enterpriseAddress.value == ""){  
  15.         errorinfo += "客户办公地址为必填项,请输入!/n";  
  16.         if(isFocus){  
  17.                     enterpriseAddress.focus();  
  18.                     isFocus = false;  
  19.         }         
  20.     }  
  21.           
  22.     var postcode = document.getElementsByName("Custom.postcode")[0];  
  23.     if (postcode.value == ""){  
  24.         errorinfo += "邮政编码为必填项,请输入!/n";  
  25.         if(isFocus){  
  26.                     postcode.focus();  
  27.                     isFocus = false;  
  28.         }                     
  29.     }else{  
  30.         var patrn=/^[a-zA-Z0-9 ]{3,12}$/;  
  31.         if (!patrn.exec(postcode.value)){  
  32.             errorinfo += "你输入的邮政编码格式不正确,请重新输入!/n";  
  33.             if(isFocus){  
  34.                         postcode.focus();  
  35.                         isFocus = false;  
  36.             }                                         
  37.         }  
  38.     }  
  39.     var checkSub = document.getElementsByName("Custom.checkSub")[0];  
  40.     if (checkSub.value == 0){  
  41.         errorinfo += "是否验证子客户为必填项,请输入!/n";  
  42.             if(isFocus){  
  43.                         checkSub.focus();  
  44.                         isFocus = false;  
  45.             }  
  46.     }  
  47.     var principalName = document.getElementsByName("Custom.principalName")[0];  
  48.     if (principalName.value == ""){  
  49.         errorinfo += "法人代表为必填项,请输入!/n";  
  50.         if(isFocus){  
  51.                     principalName.focus();  
  52.                     isFocus = false;  
  53.         }         
  54.     }  
  55.     var passportId = document.getElementsByName("Custom.passportId")[0];  
  56.     if (passportId.value == ""){  
  57.         errorinfo += "法人代表的身份证号码为必填项,请输入!/n";  
  58.         if(isFocus){  
  59.                     passportId.focus();  
  60.                     isFocus = false;  
  61.         }         
  62.     }else{  
  63.         var patrn=/^(([0-9]{14}[x0-9]{1})|([0-9]{17}[x0-9]{1}))$/;  
  64.         if (!patrn.exec(passportId.value)){  
  65.             errorinfo += "你输入法人代表的身份证号码格式不正确,请输入15位或者18位的身份证号码!/n";  
  66.             if(isFocus){  
  67.                     passportId.focus();  
  68.                     isFocus = false;  
  69.             }                             
  70.         }         
  71.     }  
  72.   
  73.     var delegateName = document.getElementsByName("DelegateInfo1.delegateName")[0];  
  74.     if (delegateName.value == ""){  
  75.         errorinfo +="客户经办人(1)姓名为必填项,请输入!/n";  
  76.         if(isFocus){  
  77.                     delegateName.focus();  
  78.                     isFocus = false;  
  79.         }                 
  80.     }  
  81.     var delegateId = document.getElementsByName("DelegateInfo1.delegateId")[0];  
  82.     if (delegateId.value == ""){  
  83.         errorinfo += "客户经办人(1)的身份证号码为必填项,请输入!/n";  
  84.         if(isFocus){  
  85.                     delegateId.focus();  
  86.                     isFocus = false;  
  87.         }                     
  88.     }else{  
  89.         var patrn=/^(([0-9]{14}[x0-9]{1})|([0-9]{17}[x0-9]{1}))$/;  
  90.         if (!patrn.exec(delegateId.value)){  
  91.                 errorinfo += "你输入的客户经办人(1)的身份证号码格式不正确,请输入15位或者18位的身份证号码!/n";  
  92.             if(isFocus){  
  93.                         delegateId.focus();  
  94.                         isFocus = false;  
  95.             }                                                 
  96.         }        
  97.     }  
  98.     var delegateDuty = document.getElementsByName("DelegateInfo1.delegateDuty")[0];  
  99.     if (delegateDuty.value == ""){  
  100.         errorinfo +="你输入客户经办人(1)的职务为必填项,请输入!/n";      
  101.             if(isFocus){  
  102.                         delegateDuty.focus();  
  103.                         isFocus = false;  
  104.             }             
  105.     }  
  106.     var delegateTelephone = document.getElementsByName("DelegateInfo1.delegateTelephone")[0];  
  107.     if (delegateTelephone.value == ""){  
  108.         errorinfo += "你输入客户经办人(1)的固定电话为必填项,请输入!/n";  
  109.             if(isFocus){  
  110.                         delegateTelephone.focus();  
  111.                         isFocus = false;  
  112.             }                     
  113.     }else{  
  114.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$/;    
  115.         if (!patrn.exec(delegateTelephone.value)){  
  116.             errorinfo += "你输入的固定电话格式不正确,请重新输入!/n";    
  117.             if(isFocus){  
  118.                         delegateTelephone.focus();  
  119.                         isFocus = false;  
  120.             }                                     
  121.         }   
  122.     }  
  123.     var delegateMobile = document.getElementsByName("DelegateInfo1.delegateMobile")[0];  
  124.     if (delegateMobile.value == ""){  
  125.         errorinfo += "你输入客户经办人(1)的移动电话为必填项,请输入!/n";  
  126.             if(isFocus){  
  127.                         delegateMobile.focus();  
  128.                         isFocus = false;  
  129.             }                 
  130.     }else{  
  131.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?13/d{9}$/;  
  132.         if (!patrn.exec(delegateMobile.value)){  
  133.             errorinfo += "你输入的移动电话格式不正确,请重新输入!/n";    
  134.             if(isFocus){  
  135.                         delegateMobile.focus();  
  136.                         isFocus = false;  
  137.             }                                 
  138.         }   
  139.     }  
  140.     var delegateFax = document.getElementsByName("DelegateInfo1.delegateFax")[0];  
  141.     if (delegateFax.value == ""){  
  142.         errorinfo += "你输入客户经办人(1)的传真为必填项,请输入!/n";  
  143.             if(isFocus){  
  144.                         delegateFax.focus();  
  145.                         isFocus = false;  
  146.             }                 
  147.     }else{  
  148.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$/;    
  149.         if (!patrn.exec(delegateFax.value)){  
  150.             errorinfo += "你输入的传真格式不正确,请重新输入!/n";  
  151.             if(isFocus){  
  152.                         delegateFax.focus();  
  153.                         isFocus = false;  
  154.             }                                             
  155.         }   
  156.     }  
  157.     var delegateEmail = document.getElementsByName("DelegateInfo1.delegateEmail")[0];  
  158.     if (delegateEmail.value == ""){  
  159.         errorinfo += "你输入客户经办人(1)的邮箱地址为必填项,请输入!/n";  
  160.             if(isFocus){  
  161.                         delegateEmail.focus();  
  162.                         isFocus = false;  
  163.             }                 
  164.     }else{  
  165.         var patrn=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;   
  166.         if (!patrn.exec(delegateEmail.value)){  
  167.             errorinfo += "你输入的邮箱地址不正确,请重新输入!/n";      
  168.             if(isFocus){  
  169.                         delegateEmail.focus();  
  170.                         isFocus = false;  
  171.             }                                     
  172.         }   
  173.     }
  174.   //-----------------------------------------2------------------  
  175.       
  176.     var delegateId2 = document.getElementsByName("DelegateInfo2.delegateId")[0];  
  177.     if (delegateId2.value != ""){         
  178.        var patrn=/^(([0-9]{14}[x0-9]{1})|([0-9]{17}[x0-9]{1}))$/;  
  179.         if (!patrn.exec(delegateId2.value)){  
  180.                 errorinfo += "你输入的客户经办人(2)身份证号码格式不正确,请输入15位或者18位的身份证号码!/n";   
  181.                 if(isFocus){  
  182.                         delegateId2.focus();  
  183.                         isFocus = false;  
  184.                 }                                 
  185.         }        
  186.     }  
  187.     var delegateTelephone2 = document.getElementsByName("DelegateInfo2.delegateTelephone")[0];  
  188.     if (delegateTelephone2.value != ""){          
  189.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$/;   
  190.         if (!patrn.exec(delegateTelephone2.value)){  
  191.             errorinfo += "你输入的的客户经办人(2)固定电话格式不正确,请重新输入!/n";  
  192.                 if(isFocus){  
  193.                         delegateTelephone2.focus();  
  194.                         isFocus = false;  
  195.                 }                                                 
  196.         }   
  197.     }  
  198.     var delegateMobile2 = document.getElementsByName("DelegateInfo2.delegateMobile")[0];  
  199.     if (delegateMobile2.value != ""){         
  200.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?13/d{9}$/;  
  201.         if (!patrn.exec(delegateMobile2.value)){  
  202.             errorinfo += "你输入的客户经办人(2)移动电话格式不正确,请重新输入!/n";  
  203.                 if(isFocus){  
  204.                         delegateMobile2.focus();  
  205.                         isFocus = false;  
  206.                 }                                             
  207.         }   
  208.     }  
  209.     var delegateFax2 = document.getElementsByName("DelegateInfo2.delegateFax")[0];  
  210.     if (delegateFax2.value != ""){        
  211.         var patrn=/^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$/;   
  212.         if (!patrn.exec(delegateFax2.value)){  
  213.             errorinfo += "你输入的客户经办人(2)传真格式不正确,请重新输入!/n";  
  214.                 if(isFocus){  
  215.                         delegateFax2.focus();  
  216.                         isFocus = false;  
  217.                 }                                         
  218.         }   
  219.     }  
  220.     var delegateEmail2 = document.getElementsByName("DelegateInfo2.delegateEmail")[0];  
  221.     if (delegateEmail2.value != ""){          
  222.         var patrn=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;   
  223.         if (!patrn.exec(delegateEmail2.value)){  
  224.             errorinfo += "你输入的客户经办人(2)邮箱地址不正确,请重新输入!/n";  
  225.                 if(isFocus){  
  226.                         delegateEmail2.focus();  
  227.                         isFocus = false;  
  228.                 }                                         
  229.         }   
  230.     }  
  231.     var delegateName2 = document.getElementsByName("DelegateInfo2.delegateName")[0];  
  232.     if (delegateId2.value != "" ||delegateTelephone2.value !="" || delegateMobile2.value != "" ||delegateFax2.value !="" || delegateEmail2.value !=""){  
  233.         if (delegateName2.value == ""){  
  234.             errorinfo+= "客户经办人(2)姓名没有输入,请输入!";  
  235.                 if(isFocus){  
  236.                         delegateName2.focus();  
  237.                         isFocus = false;  
  238.                 }                 
  239.         }  
  240.     }   
  241.     var saleOfYear = document.getElementsByName("Custom.saleOfYear")[0];  
  242.     if (saleOfYear.value != ""){  
  243.         var patrn=/^((-?|/+?)/d+)(/./d+)?$/;  
  244.         if (!patrn.exec(saleOfYear.value)){  
  245.             errorinfo += "你输入的年销售/营业额不正确,只能够为数字类型,请重新输入!/n";  
  246.                 if(isFocus){  
  247.                         saleOfYear.focus();  
  248.                         isFocus = false;  
  249.                 }                             
  250.         }  
  251.     }  
  252.     var payoutOfYear = document.getElementsByName("Custom.payoutOfYear")[0];  
  253.     if (payoutOfYear.value == ""){  
  254.         errorinfo += "你输入年估计/实际机票支出为必填项,请输入!/n";  
  255.             if(isFocus){  
  256.                         payoutOfYear.focus();  
  257.                         isFocus = false;  
  258.             }  
  259.     }  
  260.     else{  
  261.         var patrn=/^((-?|/+?)/d+)(/./d+)?$/;  
  262.         if (!patrn.exec(payoutOfYear.value)){  
  263.             errorinfo += "你输入的年估计/实际机票支出不正确,只能够为数字类型,请重新输入!/n";   
  264.                 if(isFocus){  
  265.                         payoutOfYear.focus();  
  266.                         isFocus = false;  
  267.                 }                         
  268.         }  
  269.     }  
  270.     var numberOfUser = document.getElementsByName("Custom.numberOfUser")[0];  
  271.     if (numberOfUser.value == ""){  
  272.         errorinfo += "你输入机构客户人数为必填项,请输入!/n";  
  273.                 if(isFocus){  
  274.                             numberOfUser.focus();  
  275.                             isFocus = false;  
  276.                 }     
  277.     }  
  278.     else{  
  279.         var patrn=/^[0-9]*[1-9][0-9]*$/;  
  280.         if (!patrn.exec(numberOfUser.value)){  
  281.             errorinfo += "你输入的机构客户人数不正确,只能够为整数类型,请重新输入!/n";       
  282.                 if(isFocus){  
  283.                         numberOfUser.focus();  
  284.                         isFocus = false;  
  285.                 }                 
  286.         }  
  287.     }  
  288.     var estimateTraveller = document.getElementsByName("Custom.estimateTraveller")[0];  
  289.     if (estimateTraveller.value == ""){  
  290.         errorinfo += "你输入年计划出行人数为必填项,请输入!/n";  
  291.                     if(isFocus){  
  292.                                 estimateTraveller.focus();  
  293.                                 isFocus = false;  
  294.                     }     
  295.       
  296.     }  
  297.     else{  
  298.         var patrn=/^[0-9]*[1-9][0-9]*$/;  
  299.         if (!patrn.exec(estimateTraveller.value)){  
  300.             errorinfo += "你输入的年计划出行人数不正确,只能够为整数类型,请重新输入!/n";      
  301.                 if(isFocus){  
  302.                         estimateTraveller.focus();  
  303.                         isFocus = false;  
  304.                 }                     
  305.         }  
  306.     }  
  307.     var frequentlyDestination = document.getElementsByName("Custom.frequentlyDestination")[0];  
  308.     if (frequentlyDestination.value == ""){  
  309.         errorinfo += "你输入经常出行地点为必填项,请输入!/n";  
  310.                     if(isFocus){  
  311.                                 frequentlyDestination.focus();  
  312.                                 isFocus = false;  
  313.                     }     
  314.       
  315.     }  
  316.   
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值