Dim strError

function doSubmit(frmID)

	DIM idArray, numberElements, pattern 
		strError=""
    
    ReDim idArray(document.all(frmID).length)
    
	for x = 0 to document.all(frmID).length - 1

		' Loop through the form to find all the 'text' and 'hidden' fields in the form.
		if document.all(frmID).elements(x).type = "text" or _ 
			document.all(frmID).elements(x).type = "hidden" or _  
			document.all(frmID).elements(x).type = "password" or _  
			document.all(frmID).elements(x).type = "select-one" then

		    pattern=0

		    set thisItem = document.all(frmID).elements(x)
         	' Check to see if we are using a regular expression. If
	        ' the 'VALIDATE' attribute is equal to 'regexp' then it will also need to have an
	        ' associated 'PATTERN' attribute which will either be a pre-determined regular-expression,
	        ' (see the validateField function for pre-determined regular expressions)
	        ' or you can pass your own. Otherwise, it will pass a zero to the validateField function
	        ' since we don't need the 'PATTERN' attribue if we are not using a regular expression.    	    
    	    
    	    if lcase(thisItem.validate) <> "none" then
    	    
    	    if lcase(thisItem.validate)="regexp" then
				pattern=thisItem.pattern
		    end if
		    
		    ' Pass the value of the given field, the 'VALIDATE' attributte, and the 'PATTERN'
		    ' attribute to the validateField function
		       		    
		    if not validateField(thisItem.value,thisItem.validate,pattern) then
                
                ' If the function does not return true, we add the field's id to an array.
                idArray(x)=thisItem.id
                
	        end if
	        
	        end if
			
			else
			

			
        end if
        
    next  
    
    ' strError is defined in the validateField function
    
	if strError <> "" then
	   
	   strError="The following errors were found:" & space(5) & vbcrlf & vbcrlf & strError
	   ' display errors to user
	   thisBox = msgBox(strError,16,"Errors Found")	      
	   
 	else
	   document.all(frmID).submit()
    end if

end function
