Dim strError
'****************************************************************************************
'		function doSubmit(frmID)						*
'****************************************************************************************
function doSubmit(frmID)
HTMLview2()
	DIM idArray, numberElements, pattern 
	strError=""
	  
    ReDim idArray(document.all(frmID).length)	

	for x = 0 to document.all(frmID).length - 1		
	    ' Recorro el formulario para encontrar todos los controles 'text' y 'hidden' 
	    'msgbox  document.all(frmID).elements(x).type
	    Select case  document.all(frmID).elements(x).type
	    	case "text","select-one","textarea","file" 
	    		'Estos son los tipos de objetos que va a validar el formulario, por lo tanto
	    	        '	deberan tener siempre la porpidedad VALIDATE="algo"
	    	 'msgbox "si"	    
		pattern=0
		set thisItem = document.all(frmID).elements(x)
         	' Miramos si estamos usando una expresion regular 'regexp'.
	        ' Si el atributo 'VALIDATE' es 'regexp' entonces necesitaremos asociar
	        ' el atributo 'PATTERN' el cual puede ser una 'regexp' predeterminada
	        ' o una personalizada por nosotros    	    
    	    	if lcase(thisItem.validate) <> "none" then 
    	      	   if lcase(thisItem.validate)="regexp" then
				pattern=thisItem.pattern
		   end if   
		    ' Paso el valor, el atributo 'VALIDATE' y el atributo 'PATTERN'
		    ' a la funcion validateField.     		    
		   if not validateField(thisItem.value,thisItem.validate,pattern) then
                	' Si la funcion no devuelve true, inserto el  id del campo en un array.
                	idArray(x)=thisItem.name
                
	     	   end if	        
	        end if
            end select 
    	next  
    
    ' strError esta definido en la funcion validateField
	if strError <> "" then
  	   for each z in idArray
	       if z <> "" then
	          ' cambio el color de los campos que tienen error
	          execute("document.all." & z & ".style.backgroundcolor=""#D5BBB8""")
	       end if
	   next
	   
	   strError="Se han encontrado los siguientes errores:" & space(5) & vbcrlf & vbcrlf & strError
	   ' Muestro los errores al usuario
	   thisBox = msgBox(strError,64,"Validacion del formulario")	      
	   
 	else
	   document.all(frmID).submit()
    end if

end function
