﻿' VBScript 文件

Function CheckForm()
		Dim bolSubmit
		bolSubmit = True
		Dim txtInput
		Dim txtarea
		Dim Sel
		dim i
		dim j
		dim str
		dim str1
		Set txtInput = document.all("tabData").all.tags("Input")
		Set txtarea = document.all("tabData").all.tags("textarea")
		Set Sel = document.all("tabData").all.tags("select")
		
		For i = 0 To txtarea.length - 1
	
		        If IsNull(txtarea(i).getAttribute("NumericOnly")) = False Then
			        If Len(txtarea(i).value) > 0 Then
				        If IsNumeric(txtarea(i).value) = False Then
				 	        msgbox "“" & txtarea(i).getAttribute("NumericOnly") & "”必须输入数字！",16,"修改档案"
					        txtarea(i).select()
					        txtarea(i).focus()
					        bolSubmit = False
					        CheckForm = False
					        Exit For
				        End If
			        End If
		        End If
		   
		  
		   
		   
		   
		    If IsNull(txtarea(i).getAttribute("NotNull")) = False Then
			    If Len(Trim(txtarea(i).value)) = 0 Then
				    msgbox "“" & txtarea(i).getAttribute("NotNull") & "”必须输入！",16,"警告"
				    txtarea(i).select()
				    txtarea(i).focus()
				    bolSubmit = False
				    CheckForm = False
				    Exit For
			    End If
		    End If
		    If IsNull(txtarea(i).getAttribute("DateTimeOnly")) = False Then
			    If Len(txtarea(i).value) > 0 Then
				    If IsDate(txtarea(i).value) = False Then
					    msgbox "“" & txtarea(i).getAttribute("DateTimeOnly") & "”必须输入日期！",16,"修改档案"
					    txtarea(i).select()
					    txtarea(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If

		    If IsNull(txtarea(i).getAttribute("InvertedComma")) = False Then
			    If Len(txtarea(i).value) > 0 Then
				    If InStr (txtarea(i).value,"'") >0 Then
					    msgbox "“" & txtarea(i).getAttribute("InvertedComma") & "”含有非法字符 ' 请重新输入！",16,"修改档案"
					    txtarea(i).select()
					    txtarea(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If
	    Next
		
	
	    For i = 0 To txtInput.length - 1
	    
	     If IsNull(txtInput(i).getAttribute("NumericOnly")) = False Then
			    If Len(txtInput(i).value) > 0 Then
				    If (IsNumeric(txtInput(i).value) = False or InStr(txtInput(i).value,"&") <>0 or InStr(txtInput(i).value,"d")<>0 or InStr(txtInput(i).value,"e") <>0) Then
					    msgbox "“" & txtInput(i).getAttribute("NumericOnly") & "”必须输入数字！",16,"修改档案"
					    txtInput(i).select()
					    txtInput(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If
		    
		     If IsNull(txtInput(i).getAttribute("DYL")) = False Then
			        If Len(txtInput(i).value) > 0 Then			        
			                If IsNumeric(txtInput(i).value) = True Then	
				                If (InStr(txtInput(i).value,"-") <>0 or Mid(txtInput(i).value,1,1)="0") Then
				 	                msgbox "“" & txtInput(i).getAttribute("DYL") & "”必须大于零！",16,"修改档案"
					                txtInput(i).select()
					                txtInput(i).focus()
					                bolSubmit = False
					                CheckForm = False
					                Exit For
                                End If
				            End If
				    End If
		    End If
		    
		    
		    If IsNull(txtInput(i).getAttribute("ZS")) = False Then
			        If Len(txtInput(i).value) > 0 Then			        
			                If IsNumeric(txtInput(i).value) = True Then	
				                If InStr(txtInput(i).value,".") <>0 Then
				 	                msgbox "“" & txtInput(i).getAttribute("ZS") & "”必须是整数！",16,"修改档案"
					                txtInput(i).select()
					                txtInput(i).focus()
					                bolSubmit = False
					                CheckForm = False
					                Exit For
                                End If
				            End If
				    End If
		    End If
		    
		     If IsNull(txtInput(i).getAttribute("QJZBJ")) = False Then
			        If Len(txtInput(i).value) > 0 Then			        
			                If IsNumeric(txtInput(i).value) = True Then
			                    For j=1 to len(txtInput(i).value) 
			                        str1=Asc(mid(txtInput(i).value,j,1))
			                        If  str1 < 0 Then
			                            str=str&chr(str1+23680)
				 	                    txtInput(i).select()
					                    txtInput(i).focus()
					                Else
					                   str=str&chr(str1)
					                End If
					            Next
					            IF Asc(txtInput(i).value) < 0 Then
					                msgbox "“" & txtInput(i).getAttribute("QJZBJ") & "”输入了全角已转为半角,请再次点击保存！",16,"修改档案"
					                bolSubmit = False
					                CheckForm = False
					            End If
					            txtInput(i).value=str
					        End If
				    End If
		    End If
		    
		   
		    If IsNull(txtInput(i).getAttribute("NotNull")) = False Then
			    If Len(Trim(txtInput(i).value)) = 0 Then
				    msgbox "“" & txtInput(i).getAttribute("NotNull") & "”必须输入！",16,"警告"
				    txtInput(i).select()
				    txtInput(i).focus()
				    bolSubmit = False
				    CheckForm = False
				    Exit For
			    End If
		    End If
		    If IsNull(txtInput(i).getAttribute("DateTimeOnly")) = False Then
			    If Len(txtInput(i).value) > 0 Then
				    If IsDate(txtInput(i).value) = False Then
					    msgbox "“" & txtInput(i).getAttribute("DateTimeOnly") & "”必须输入日期！",16,"修改档案"
					    txtInput(i).select()
					    txtInput(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If

		    If IsNull(txtInput(i).getAttribute("InvertedComma")) = False Then
			    If Len(txtInput(i).value) > 0 Then
				    If InStr (txtInput(i).value,"'") >0Then
					    msgbox "“" & txtInput(i).getAttribute("InvertedComma") & "”含有非法字符 ' 请重新输入！",16,"修改档案"
					    txtInput(i).select()
					    txtInput(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If
	    Next
		
		
		
		
		
		For i = 0 To Sel.length - 1
		    If IsNull(Sel(i).getAttribute("NumericOnly")) = False Then
			    If Len(Sel(i).value) > 0 Then
				    If IsNumeric(Sel(i).value) = False Then
					    msgbox "“" & Sel(i).getAttribute("NumericOnly") & "”必须输入数字！",16,"修改档案"
					    Sel(i).select()
					    Sel(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If
		    If IsNull(Sel(i).getAttribute("NotNull")) = False Then
			    If Len(Trim(Sel(i).value)) = 0 Then
				    msgbox "“" & Sel(i).getAttribute("NotNull") & "”必须输入！",16,"警告"
				    Sel(i).select()
				    Sel(i).focus()
				    bolSubmit = False
				    CheckForm = False
				    Exit For
			    End If
		    End If
		    If IsNull(Sel(i).getAttribute("DateTimeOnly")) = False Then
			    If Len(Sel(i).value) > 0 Then
				    If IsDate(Sel(i).value) = False Then
					    msgbox "“" & Sel(i).getAttribute("DateTimeOnly") & "”必须输入日期！",16,"修改档案"
					    Sel(i).select()
					    Sel(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If

		    If IsNull(Sel(i).getAttribute("InvertedComma")) = False Then
			    If Len(Sel(i).value) > 0 Then
				    If InStr (Sel(i).value,"'") >0Then
					    msgbox "“" & Sel(i).getAttribute("InvertedComma") & "”含有非法字符 ' 请重新输入！",16,"修改档案"
					    Sel(i).select()
					    Sel(i).focus()
					    bolSubmit = False
					    CheckForm = False
					    Exit For
				    End If
			    End If
		    End If
	    Next
	End Function
