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" 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 end if next ' strError is defined in the validateField function if strError <> "" then for each z in idArray if z <> "" then ' change the background color of text fields that contain errors execute("document.all." & z & ".style.backgroundcolor=""#D5BBB8""") end if next 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