//判斷數據的正確性
           var idSpans= new Array();
           idSpans[0] = new Array("item_2","^[\\s\\S]{1,16}$","productName","產品名稱應在1-16字以內","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);
           idSpans[1] = new Array("item_3_2","^[\\s\\S]+$","iditem_3_2Spans","商機分類不能為空","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);
           idSpans[2] = new Array("item_4","^[\\s\\S]+$","iditem_4Spans","產品系列不能為空","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);
           idSpans[3] = new Array("item_5_1","^[\\s\\S]{2,30}$","iditem_5_1Spans","商機產地長度應在2-30字以內","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",false);
           idSpans[4] = new Array("item_5_2","^[\\s\\S]{2,30}$","idItem_5_2Spans","商機產地長度應在2-30字以內","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",false);
           idSpans[5] = new Array("item_5_4","^[\\d]+$","iditem_5_4Spans","商機數量是數字格式","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",false);
           idSpans[6] = new Array("item_5_6","^[0-9]+[\\.]?[0-9]*$","iditem_5_6Spans","單價只能由數字和小數點組成!!","正確",false);
           idSpans[7] = new Array("item_7","^[\\s\\S]{16,}$","productContent","詳細說明不能小于16個字","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);
           idSpans[8] = new Array("item_8_2","^[\\s\\S]+$","iditem_8_2Spans","文件名稱不能為空","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);
           idSpans[9] = new Array("img_1_1","^[\\s\\S]+$","idimg_1Spans","圖片不能為空","<img src='http://www.www.com/office/style/1/img/right.gif' border='0'>",true);


           var reg ;
           var textValue;
           for(var i=0;i<idSpans.length;i++)
           {
           
              reg = new RegExp(idSpans[i][1], "igm");
              textValue = document.getElementById(idSpans[i][0]).value;
              if(textValue.length>0||idSpans[i][5])
              {
            
                  if(reg.test(textValue))
                  {
                 
                      document.getElementById(idSpans[i][2]).innerHTML="<font color='green'>"+idSpans[i][4]+"</font>";
                  }
                  else
                  {
                      try
                      {
                      document.getElementById(idSpans[i][0]).focus();
                      }
                      catch(e)
                      {
                      alert(e.message);
                      }
                      document.getElementById(idSpans[i][2]).innerHTML="<font color='red'>"+idSpans[i][3]+"</font>";
                  return false;
                  }
              }
            
           }


          文章來源:http://www.cnblogs.com/wangdetian168/archive/2008/11/08/1329714.html
          posted on 2010-10-09 10:57 sanmao 閱讀(129) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 嘉鱼县| 兰州市| 安化县| 龙山县| 芦山县| 日照市| 买车| 泰顺县| 麟游县| 土默特右旗| 建水县| 东丰县| 山东省| 清远市| 周口市| 平顶山市| 禹州市| 登封市| 红河县| 云龙县| 汶川县| 滕州市| 新竹市| 筠连县| 无棣县| 西宁市| 叙永县| 大宁县| 新营市| 九江县| 财经| 清流县| 合川市| 宁城县| 宜丰县| 洛宁县| 聂荣县| 左云县| 乌拉特前旗| 胶州市| 新安县|