http://140.56.16.120/index/wsbs/kydj-2.jsp?qy=370901大不开啊!而且客户端校验也没什么捷径可言,用你写的方法吧

解决方案 »

  1.   

    对了,网址错了。
    http://www.sdta-l-tax.gov.cn/index/wsbs/kydj-2.jsp?qy=370901
      

  2.   

    下面是我以前的代码,主要是在input里加入自己的标记,如cn:中文名,needed:是否必须,datatype:数据类型
    可以通用于任何表格 // to each element in a 'html form', we added 3 new attribute, 'cn', 'needed' and 'datatype'
    // cn          is the Chinese name of the element for alert to the users.
    // needed      if equals '*', then the value of the element is needed
    // datatype    's', mean it is a String data
    //             'n', mean it is a Numberic
    //             'd', mean it is a Datetime data
    //             'e', mean it is a E-mail link
    function checkForm(theForm){
    var item;
    for(item in theForm.all){
    if(theForm.all[item].needed && theForm.all[item].needed == "*")
    if(theForm.all[item].type.substr(0, 6) == 'select'){
    if(theForm.all[item].selectedIndex == 0){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须填写!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();
    return false;
    }
    }
    else if(!theForm.all[item].value || theForm.all[item].value.length == 0){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须填写!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();
    return false;
    }

    if(theForm.all[item].datatype)
    switch(theForm.all[item].datatype.charAt(0)){
    case 's':
    break;
    case 'n':
    if(!checkNumber(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为阿拉伯数字!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    case 'd':
    if(!checkDate(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为 yyyy-mm-dd 格式日期!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    case 'e':
    if(!checkEmail(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为 E-mail 格式!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    }
    }
    for(item in theForm.all)
    theForm.all[item].disabled = false;
    return true;
    }
    function checkNumber(theValue){
    if(theValue)
    for(i = 0; i < theValue.length; i ++)
    if(theValue.charAt(i) != '.' && !(theValue.charAt(i) >=0 && theValue.charAt(i) <=9))
    return false;
    return true;
    }
    function checkDate(theValue){
    if(theValue && theValue.length > 0){
    if(theValue.length < 8) return false;
    if(theValue.charAt(4) != '.' && theValue.charAt(4) != '-') return false;

    sy = theValue.substring(0, 4);

    if(theValue.charAt(6) == '.' || theValue.charAt(6) == '-'){
    sm = theValue.substring(5, 6);
    sd = theValue.substring(7);
    }
    else if(theValue.charAt(7) == '.' || theValue.charAt(7) == '-'){
    sm = theValue.substring(5, 7);
    sd = theValue.substring(8);
    }

    if(!checkNumber(sy) || !checkNumber(sm) || !checkNumber(sd))
    return false;
    }
    return true;
    }
    function checkEmail(theValue){
    if(theValue && theValue.length > 0){
    var i1, i2
    i1 = theValue.indexOf('@');
    i2 = theValue.indexOf('.', i1 + 1);
    if(i1 <= 0 || i2 <= i1) return false;
    }
    return true;
    }
      

  3.   

    重贴一扁
    // to each element in a 'html form', we added 3 new attribute, 'cn', 'needed' and 'datatype'
    // cn          is the Chinese name of the element for alert to the users.
    // needed      if equals '*', then the value of the element is needed
    // datatype    's', mean it is a String data
    //             'n', mean it is a Numberic
    //             'd', mean it is a Datetime data
    //             'e', mean it is a E-mail link
    function checkForm(theForm){
    var item;
    for(item in theForm.all){
    if(theForm.all[item].needed && theForm.all[item].needed == "*")
    if(theForm.all[item].type.substr(0, 6) == 'select'){
    if(theForm.all[item].selectedIndex == 0){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须填写!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();
    return false;
    }
    }
    else if(!theForm.all[item].value || theForm.all[item].value.length == 0){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须填写!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();
    return false;
    }

    if(theForm.all[item].datatype)
    switch(theForm.all[item].datatype.charAt(0)){
    case 's':
    break;
    case 'n':
    if(!checkNumber(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为阿拉伯数字!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    case 'd':
    if(!checkDate(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为 yyyy-mm-dd 格式日期!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    case 'e':
    if(!checkEmail(theForm.all[item].value)){
    alert(theForm.all[item].cn + "(" + theForm.all[item].name + ")" + " 必须为 E-mail 格式!");
    if(!theForm.all[item].disabled)theForm.all[item].focus();theForm.all[item].focus();
    return false;
    }
    break;
    }
    }
    for(item in theForm.all)
    theForm.all[item].disabled = false;
    return true;
    }
    function checkNumber(theValue){
    if(theValue)
    for(i = 0; i < theValue.length; i ++)
    if(theValue.charAt(i) != '.' && !(theValue.charAt(i) >=0 && theValue.charAt(i) <=9))
    return false;
    return true;
    }
    function checkDate(theValue){
    if(theValue && theValue.length > 0){
    if(theValue.length < 8) return false;
    if(theValue.charAt(4) != '.' && theValue.charAt(4) != '-') return false;

    sy = theValue.substring(0, 4);

    if(theValue.charAt(6) == '.' || theValue.charAt(6) == '-'){
    sm = theValue.substring(5, 6);
    sd = theValue.substring(7);
    }
    else if(theValue.charAt(7) == '.' || theValue.charAt(7) == '-'){
    sm = theValue.substring(5, 7);
    sd = theValue.substring(8);
    }

    if(!checkNumber(sy) || !checkNumber(sm) || !checkNumber(sd))
    return false;
    }
    return true;
    }
    function checkEmail(theValue){
    if(theValue && theValue.length > 0){
    var i1, i2
    i1 = theValue.indexOf('@');
    i2 = theValue.indexOf('.', i1 + 1);
    if(i1 <= 0 || i2 <= i1) return false;
    }
    return true;
    }