<!--

function validateForm(idForm)
{
	// INICIALIZAMOS EL RESULTADO DE LA VALIDACIÓN, SI AL FINAL DEL RECORRIDO DEL ARRAY LA VARIABLE txtValidation PERMANECE A NULL,
	// LA VALIDACIÓN ES POSITIVA Y LA PÁGINA PUEDE CONTINUAR CON EL PROCESO, SI NO ES ASÍ, SE MUESTRA EL MENSAJE DE ERROR txtValidation Y
	// SE REINICIAN LAS VARIABLES A SU VALOR INICIAL NULO
	var txtValidation = "";

	var tiposValidacion = new Array('', 'Alfa Numerico', 'Alfa', 'Numerico', 'Login', 'Password', 'Nif', 'Cif', 'Email', 'Fecha', 'Telefono', 'Tarjeta de Crédito')

	// i recorrerá el arrayFieldsToValidate
	var i = 0;

	while(i < arrayFieldsToValidate.length)
	{
		if(arrayFieldsToValidate[i][2] == 1 && document.getElementById(arrayFieldsToValidate[i][0]).value == '')
		{
			txtValidation += "El campo \""+(arrayFieldsToValidate[i][3])+"\" es obligatorio y debe rellenarse.\n";
		}
		if(arrayFieldsToValidate[i][0] != '')
		{
			// SI LA VALIDACIÓN RETORNA UN FALSE SE AÑADE
			if( !validateFields(arrayFieldsToValidate[i][0], arrayFieldsToValidate[i][1]) )
			{
				txtValidation += "El campo \""+(arrayFieldsToValidate[i][3])+"\" no es valid@.\n";
			}
		}
		i++;
	}
	if(txtValidation != '')
	{
		txtValidation += "\nPor favor realice las modificaciones necesarias y vuelva a intentarlo.\nDisculpe las molestias.";
		alert("Estimado usuario:\n\n"+txtValidation);
	}
	else
	{
		document.getElementById(idForm).submit();
	}

	var ultimaEntrada = '';
}

function validateFields(id, tipoValidacion)
{
		switch(tipoValidacion)
		{
			case '1': // ALFA NUMERICO
			{
				return isAlfaNumeric(id , 'alfanumeric');
				break;
			}

			case '2': // ALFA
			{
				return isAlfaNumeric(id , 'alfa');
				break;
			}

			case '3': // NUMERICO
			{

				return isNumeric(id , 'numeric');
				break;
			}

			case '4': // LOGIN
			{
				return isLoginPassword(id);
				break;
			}
			case '5': // PASSWORD
			{
				return isLoginPassword(id);
				break;
			}

			case '6': // NIF
			{
				return isNif(id);
				break;
			}

			case '7': // CIF
			{
				return true;
				break;
			}

			case '8': // EMAIL
			{
				return isEmail(id);
				break;
			}

			case '9': // FECHA
			{
				return isDate(id);
				break;
			}

			case '10': // TELEFONO
			{
				return true;
				break;
			}

			case '11': // CREDIT CARD
			{
				return true;
				break;
			}
			default:
			{
				return true;
				break;
			}
		}
}

	var ultimaEntrada = '';

	function changetxtAyuda(field)
	{
		if(!(ultimaEntrada != field && ultimaEntrada != '' && arrayFields[field][2] == 1 && document.getElementById(field).value == '' ))
		{
			document.getElementById('spantxtError').innerHTML = "El campo: "+arrayFields[field][3]+ "  "+arrayFields[field][1];
			ultimaEntrada = field;
		}
	}

	function validateField(field)
	{

			//alert(arrayFields[field][2]+' '+document.getElementById(field).value);
			var txtMessage = '';
			if(!(ultimaEntrada != field && ultimaEntrada != '' && arrayFields[field][2] == 1 && document.getElementById(field).value == '' ))
			{
				if(arrayFields[field][2] == 1 && document.getElementById(field).value == '')
				{
					txtMessage = 'El campo '+arrayFields[field][3]+' es obligatorio.<br> ';
				}
				if(document.getElementById(field).value != '')
				{
					if(!validateFields(field, arrayFields[field][0]))
					{
						txtMessage = 'El campo '+arrayFields[field][3]+' '+arrayFields[field][1]+'.';
					}
				}

				if(txtMessage != '')
				{
					document.getElementById('tdtxtError').style.background='#C60000';
					document.getElementById('tdtxtError_l').style.background='#C60000';
					document.getElementById('tdtxtError').style.color ='#ffffff';
					document.getElementById('spantxtError').innerHTML = txtMessage;
					document.getElementById(field).style.border = "1px dashed #C60000";
					ultimaEntrada = field;
					document.getElementById(field).focus();
				}
				else
				{
					if(ultimaEntrada == field)
					{
						ultimaEntrada = '';
						document.getElementById('tdtxtError').style.background='#F2F9F9';
						document.getElementById('tdtxtError_l').style.background = '#F2F9F9';
						document.getElementById(field).style.border = "1px solid #Cccccc";
						document.getElementById('tdtxtError').style.color = "#999999";
						document.getElementById('spantxtError').innerHTML = 'Aquí verá las condiciones de relleno de cada campo en el que entre.';
					}
					else
					{
						document.getElementById(field).style.border = "1px solid #Cccccc";
					}

				}
			}

	}

-->
