Js校验-一个跌代列表的校验

Js校验-一个跌代列表的校验
  1  <% @ page pageEncoding = " GBK " %>
  2  <% @ include file = " ../public/appcontext.jsp " %>
  3  < html >
  4       < head >
  5           < title > 模块基本信息 </ title >
  6           < logic:notEqual name = " moduleInfoForm "  property = " maModbaseinfo.ar "
  7              value = " 1 " >
  8               < script language = " javascript " >     
  9               // 记录页面展示条数
 10              var count = 0 ;
 11               /**
 12              *校验页面输入的合法性,通过则保存
 13               */     
 14              function toSave(operation) {
 15                  with (document.forms[ 0 ]) {    
 16                       // 循环判断输入信息是否合法            
 17                       for (i = 0 ;i < count;i ++ ){
 18                           if (document.all( ' moduleInfoList[ ' + i + ' ].mon ' ) != null ) {                        
 19                              document.all( ' moduleInfoList[ ' + i + ' ].mon ' ).value = trim(document.all( ' moduleInfoList[ ' + i + ' ].mon ' ).value);
 20                               if (document.all( ' moduleInfoList[ ' + i + ' ].mon ' ).value == "" ){
 21                                  alert( " 警告:请输入[模块名称]的值! " );
 22                                  document.all( ' moduleInfoList[ ' + i + ' ].mon ' ).focus();
 23                                   return   false ;
 24                              }                            
 25                          } else {
 26                              alert( " 警告:请输入[模块名称]的值! " );
 27                              document.all( ' moduleInfoList[ ' + i + ' ].mon ' ).focus();
 28                               return   false ;
 29                          }
 30                           if (document.all( ' moduleInfoList[ ' + i + ' ].smce ' ) != null ) {       
 31                              var str  = trim(document.all( ' moduleInfoList[ ' + i + ' ].smce ' ).value);
 32                               if ((str == " 0.00 " ||  (str == "" )){
 33                                  alert( " 警告:请输入[估计模块规模]的值! " );
 34                                  document.all( ' moduleInfoList[ ' + i + ' ].smce ' ).focus();
 35                                   return   false ;
 36                              }
 37                               if (str.length > 6 ){
 38                                  document.all( ' moduleInfoList[ ' + i + ' ].smce ' ).value  =  str.substr( 0 , 1 ) + str.substr( 2 ,str.length);                            
 39                              }
 40                          } else {
 41                              alert( " 警告:请输入[估计模块规模]的值! " );
 42                              document.all( ' moduleInfoList[ ' + i + ' ].smce ' ).focus();
 43                               return   false ;
 44                          }
 45                           if (document.all( ' moduleInfoList[ ' + i + ' ].smu ' ) != null ) {
 46                              document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).value = trim(document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).value);
 47                               if (document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).value == " 2 " ){
 48                                  var str = document.all( ' moduleInfoList[ ' + i + ' ].smce ' ).value;
 49                                  var s  =  str.substr(str.length - 2 ,str.length - 1 );
 50                                   if (s != " 00 " ){
 51                                      alert( " 警告:[代码规模单位]选择功能点时,[估计代码规模]应为整数! " );
 52                                      document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).focus();
 53                                       return   false ;
 54                                  }
 55                              }
 56                               if (document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).value == "" ){
 57                                  alert( " 警告:请输入[代码规模单位]的值! " );
 58                                  document.all( ' moduleInfoList[ ' + i + ' ].smu ' ).focus();
 59                                   return   false ;
 60                              }
 61                          }                        
 62                          var ontext = trim(document.all( ' moduleInfoList[ ' + i + ' ].on ' ).value);
 63                           if (ontext == null || ontext == "" ) {
 64                              alert( " 警告:请输入[操作人]的值! " );
 65                              document.all( ' moduleInfoList[ ' + i + ' ].on ' ).focus();
 66                               return   false ;                                                        
 67                          } else {                        
 68                              var patrn =/^ [ 0 - 9 ]{ 6 }$ /
 69                               if  ( ! patrn.exec(document.all( ' moduleInfoList[ ' + i + ' ].on ' ).value)){
 70                                  alert( " 警告:[操作人]的值为6位员工号,请重新输入! " ); 
 71                                  document.all( ' moduleInfoList[ ' + i + ' ].on ' ).focus();
 72                                   return   false
 73                               }
 74                          } 
 75                           if (document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ) != null ) {     
 76                              document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ).value = trim(document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ).value);
 77                               if ((document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ).value == "" ) || (document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ).value == null )){
 78                                  alert( " 警告:请输入第 " + (i + 1 ) + " 行[操作日期]的值! " );
 79                                  document.all( ' moduleInfoList[ ' + i + ' ].operdateStr ' ).focus();
 80                                   return   false ;
 81                              }                                                        
 82                          }            
 83                      }    
 84                  action  = " <%=root%>/moduleInfoAction.do?method= " + operation; 
 85                  submit();      
 86                  }
 87          }
 88                   /**
 89              *删除方法
 90               */     
 91              function toRemove(modid) {
 92              with (document.forms[ 0 ]) {
 93                   if (confirm( " 确定删除此条信息? " )){
 94                      count -- ;
 95                      action  = " <%=root%>/moduleInfoAction.do?method=doDel&id= " + modid; 
 96                         submit();  
 97                      } else {
 98                           return   false ;
 99                      }           
100                 }
101            }           
102       </ script >
103           </ logic:notEqual >
104       </ head >
105       < body >
106           < common:form action = " /moduleInfoAction.do "  method = " post " >
107               < html:hidden name = " moduleInfoForm "  property = " inid "  styleId = " inid "   />
108               < html:hidden name = " moduleInfoForm "  property = " maModbaseinfo.ar "
109                  styleId = " shFlag "   />
110               < html:hidden name = " moduleInfoForm "  property = " proQueryFlag "
111                  styleId = " proQueryFlag "   />
112               < div align = " center " >
113                   < table width = " 95% "  border = " 0 "  cellpadding = " 0 "  cellspacing = " 1 " >
114                       < tr >
115                           < td colspan = " 5 "  align = " left "   class = " line2 " >
116                               < html:errors  />
117                               < html:messages id = " message "  message = " true " >
118                                   < bean:write name = " message "  filter = " false "   />
119                               </ html:messages >
120                           </ td >
121                       </ tr >
122                   </ table >
123                   < logic:equal name = " moduleInfoForm "  property = " proQueryFlag "  value = " 1 " >
124                       < table >
125                           < tr >
126                               < td colspan = " 9 "  align = " center "   class = " line2 " >
127                                   < font color = " red " >  请先录入项目信息!  </ font >
128                               </ td >
129                           </ tr >
130                       </ table >
131                   </ logic:equal >
132                   < logic:notEqual name = " moduleInfoForm "  property = " proQueryFlag "
133                      value = " 1 " >
134                       < table width = " 95% "  border = " 1 "  cellpadding = " 0 "  cellspacing = " 1 " >
135                           < thead >
136                               < tr >
137                                   < th align = " center "  colspan = " 12 "   class = " line2 " >
138                                      模块基本信息
139                                   </ th >
140                               </ tr >
141                               < tr >
142                                   < td  class = " td1 "  align = " center "  nowrap >
143                                      模块编号
144                                   </ td >
145                                   < td  class = " td1 "  align = " center "  nowrap >
146                                      模块名称
147                                   </ td >
148                                   < td  class = " td1 "  align = " center "  nowrap >
149                                      估计模块规模
150                                   </ td >
151                                   < td  class = " td1 "  align = " center "  nowrap >
152                                      代码规模单位
153                                   </ td >
154                                   < td  class = " td1 "  align = " center "  nowrap >
155                                      操作人
156                                   </ td >
157                                   < td  class = " td1 "  align = " center "  nowrap >
158                                      操作日期
159                                   </ td >
160                                   < td  class = " td1 "  align = " center "  nowrap >
161                                      审核人
162                                   </ td >
163                                   < td  class = " td1 "  align = " center "  nowrap >
164                                      审核日期
165                                   </ td >
166                                   < td  class = " td1 "  align = " center "  nowrap >
167                                      审核意见
168                                   </ td >
169                                   < logic:notEqual name = " moduleInfoForm "  property = " maModbaseinfo.ar "
170                                      value = " 1 " >
171                                       < td  class = " td1 "  align = " center "  width = " 34 "  nowrap >
172                                          操作
173                                       </ td >
174                                   </ logic:notEqual >
175                               </ tr >
176                           </ thead >
177                           < logic:notEqual name = " moduleInfoForm "  property = " maModbaseinfo.ar "
178                              value = " 1 " >
179                               < logic:notEmpty name = " moduleInfoForm "  property = " moduleInfoList " >
180                                   < tbody id = " docTbody " >
181                                       < logic:iterate name = " moduleInfoForm "  property = " moduleInfoList "
182                                          id = " moduleInfoList "  indexId = " index " >
183                                           <% int  idx  =  index.intValue();
184                                            String nodel  =   " nodel_ " +  idx  + " _ " ;
185                                            String del  =   " del_ " +  idx  + " _ " ;
186                                       %>
187                                           < tr >
188                                               < td nowrap >
189                                                   < common:hidden name = " moduleInfoList "  property = " operFlag "
190                                                      styleId = " operFlag "  indexed = " true "   />
191                                                   < common:hidden name = " moduleInfoList "  property = " ar "
192                                                      styleId = " ar "  indexed = " true "   />
193                                                   < Script language = " javascript " > count ++ ; </ script >
194                                                   < common:text name = " moduleInfoList "  property = " id "
195                                                      styleId = " id "  empty = " true "  label = " 模块编号 "
196                                                      style = " border:none;background:none; "  validator = " text(0,6) "
197                                                      size = " 6 "  indexed = " true "  readonly = " true "   />
198                                               </ td >
199                                               < td nowrap >
200                                                   < common:text name = " moduleInfoList "  property = " mon "
201                                                      styleId = " mon "  empty = " false "  label = " 模块名称 "
202                                                      validator = " text(0,20) "  size = " 11 "  indexed = " true "   />
203                                               </ td >
204                                               < td nowrap >
205                                                   < common:text name = " moduleInfoList "  property = " smce "
206                                                      styleId = " smce "  empty = " false "  label = " 估计模块规模 "
207                                                      validator = " Decimal(6,2) "  size = " 6 "  indexed = " true "   />
208                                               </ td >
209                                               < td nowrap >
210                                                   < param:select name = " moduleInfoList "  property = " smu "
211                                                      label = " 代码规模单位 "  empty = " false "  nullStr = " 请选择 "  styleId = " smu "
212                                                      type = " smuTag "  indexed = " true "  withCode = " false "   />
213                                               </ td >
214                                               < td nowrap >
215                                                   < common:text name = " moduleInfoList "  property = " on "
216                                                      styleId = " on "  empty = " false "  label = " 操作人 "  validator = " text(0,6) "
217                                                      size = " 6 "  indexed = " true "   />
218                                               </ td >
219                                               < td nowrap >
220                                                   < common:text styleClass = " input "  name = " moduleInfoList "
221                                                      property = " operdateStr "  styleId = " operdateStr "  empty = " false "
222                                                      label = " 操作日期 "  size = " 10 "  onclick = " setday(this) "
223                                                      validator = " text(0,10) "  readonly = " true "  indexed = " true "   />
224                                               </ td >
225                                               < td nowrap align = " right " >
226                                                   < common:text name = " moduleInfoList "  property = " an "
227                                                      styleId = " an "  empty = " true "  label = " 审核人 "  validator = " text(0,6) "
228                                                      size = " 6 "  indexed = " true "
229                                                      style = " border:none;background:none; "  readonly = " true "   />
230                                               </ td >
231                                               < td nowrap align = " center " >
232                                                   < common:text name = " moduleInfoList "  property = " adStr "
233                                                      styleId = " adStr "  empty = " true "  label = " 审核日期 "
234                                                      validator = " text(0,10) "  size = " 10 "
235                                                      style = " border:none;background:none; "  indexed = " true "
236                                                      readonly = " true "   />
237                                               </ td >
238                                               < td nowrap >
239                                                   < common:textarea styleId = " ac "  label = " 审核意见 "
240                                                      validator = " text(0,255) "  empty = " true "  name = " moduleInfoList "
241                                                      property = " ac "  readonly = " true "
242                                                      style = " border:none;background:none;overflow:auto "
243                                                      indexed = " true "   />
244                                               </ td >
245                                               < td width = " 34 " >
246                                                   < div id = " <%=nodel%> "  style = " display:inline " >
247                                                       < logic:equal name = " moduleInfoList "  property = " operFlag "
248                                                          value = " 1 " >
249                                                           --
250                                                       </ logic:equal >
251                                                       < logic:equal name = " moduleInfoList "  property = " operFlag "
252                                                          value = " 0 " >
253                                                           < a href = " # "
254                                                              onclick = " toRemove('<bean:write name= " moduleInfoList "  property= " id " />') " > 删除 </ a >
255                                                       </ logic:equal >
256                                                   </ div >
257                                                   < div id = " <%=del%> "  style = " display:none " >
258                                                       < a href = " # "
259                                                          onclick = " if(confirm('是否确定删除此费用信息?')){editableTable.removeRow(<bean:write name='index'/>);count--;} "
260                                                          style = " CURSOR: hand; " > 删除 </ a >
261                                                   </ div >
262                                               </ td >
263                                           </ tr >
264                                       </ logic:iterate >
265                                   </ tbody >
266                               </ logic:notEmpty >
267                               < tr >
268                                   < td nowrap colspan = " 10 "  align = " right " >
269                                       < a href = " # "  onclick = " addRows() " > 添加 & nbsp; </ a >
270                                   </ td >
271                               </ tr >
272                               < tr >                                 
273                                   < td nowrap colspan = " 10 "  align = " center " >
274                                       < input type = " button "  value = "  保存  "  name = " btnSave "   class = " btn "
275                                          onclick = " toSave('doSave') "   />
276                                   </ td >
277                               </ tr >
278                           </ logic:notEqual >
279                           < logic:equal name = " moduleInfoForm "  property = " maModbaseinfo.ar "
280                              value = " 1 " >
281                               < logic:notEmpty name = " moduleInfoForm "  property = " moduleInfoList " >
282                                   < tbody >
283                                       < logic:iterate name = " moduleInfoForm "  property = " moduleInfoList "
284                                          id = " data "  indexId = " index " >
285                                           < tr >
286                                               < td nowrap align = " center " >
287                                                   < bean:write name = " data "  property = " id "   />
288                                               </ td >
289                                               < td nowrap >
290                                                   < bean:write name = " data "  property = " mon "   />
291                                               </ td >
292                                               < td nowrap align = " right " >
293                                                   < bean:write name = " data "  property = " smce "   />
294                                               </ td >
295                                               < td nowrap align = " right " >
296                                                   < bean:write name = " data "  property = " smu "   />
297                                               </ td >
298                                               < td nowrap align = " right " >
299                                                   < bean:write name = " data "  property = " on "   />
300                                               </ td >
301                                               < td nowrap align = " center " >
302                                                   < bean:write name = " data "  property = " operdate "
303                                                      format = " yyyy-MM-dd "   />
304                                               </ td >
305                                               < td nowrap align = " right " >
306                                                   < bean:write name = " data "  property = " an "   />
307                                               </ td >
308                                               < td nowrap align = " center " >
309                                                   < bean:write name = " data "  property = " ad "  format = " yyyy-MM-dd "   />
310                                               </ td >
311                                               < td nowrap >
312                                                   < html:textarea name = " data "  property = " ac "  readonly = " true "   />
313                                               </ td >
314                                           </ tr >
315                                       </ logic:iterate >
316                                       < tr >
317                                           < td colspan = " 9 "  align = " center " >
318                                               < font color = " red " >  审核已通过,如需改动,请联系审核人!  </ font >
319                                           </ td >
320                                       </ tr >
321                                   </ tbody >
322                               </ logic:notEmpty >
323                           </ logic:equal >
324                       </ table >
325                   </ logic:notEqual >
326               </ div >
327           </ common:form >
328           < logic:notEqual name = " moduleInfoForm "  property = " maModbaseinfo.ar "
329              value = " 1 " >
330               < script language = " javascript " >
331               /**
332              *添加一行
333               */
334                 var editableTable = new  EditableTable( " docTbody " , false , " id_0_ " , " operFlag_0_ " );
335                 function addRows(){
336                  editableTable.addRow();
337                  count ++ ;
338                   // 得到新加的行号
339                  var new_idx  =  document.all( " docTbody " ).childNodes.length  -   1 ;
340                   // 清空
341                  document.getElementById( " id_ " + new_idx + " _ " ).value = "" ;
342                  document.getElementById( " mon_ " + new_idx + " _ " ).value = "" ;
343                  document.getElementById( " smce_ " + new_idx + " _ " ).value = "" ;
344                  document.getElementById( " smu_ " + new_idx + " _ " ).value = "" ;
345                  document.getElementById( " on_ " + new_idx + " _ " ).value = "" ;
346                  document.getElementById( " operdateStr_ " + new_idx + " _ " ).value = "" ;
347                  document.getElementById( " an_ " + new_idx + " _ " ).value = "" ;
348                  document.getElementById( " adStr_ " + new_idx + " _ " ).value = "" ;
349                  document.getElementById( " ac_ " + new_idx + " _ " ).value = "" ;
350                   // 显示删除连接                
351                  document.getElementById( " nodel_ " + new_idx + " _ " ).style.display = " none " ;
352                  document.getElementById( " del_ " + new_idx + " _ " ).style.display = " inline " ;
353              }
354             </ script >
355           </ logic:notEqual >
356       </ body >
357  </ html >
358 
359 

你可能感兴趣的:(Js校验-一个跌代列表的校验)