<!---------- JavaScript
var caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

// ***********************************************************
// Funcion de validacion del formulario
// ***********************************************************
function ValidaDatos(form){

//	with(document.forms[0])
	with(form)
	{
		if (tnombre.value.length < 3){ 
			alert('Debes escribir tu Nombre antes enviar la consulta.');tnombre.focus();}
		else if (!validaCampo(tnombre.value) || tnombre.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en el Nombre.');tnombre.focus();}
		else if (tapellido1.value.length < 3) {
			alert('Debes escribir tu 1er. Apellido antes enviar la consulta.');tapellido1.focus();}
		else if (!validaCampo(tapellido1.value) || tapellido1.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en 1er. Apellido.');tapellido1.focus();}
		else if (tapellido2.value.length < 3) {
			alert('Debes escribir tu 2 Apellido antes enviar la consulta.');tapellido2.focus();}
		else if (!validaCampo(tapellido2.value) || tapellido2.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en 2 Apellido.');tapellido2.focus();}

		else if (!validaDia(tday.value,tmonth.value,tyear.value)) {
			alert('Datos incorrectos. Error al introducir el Da');tday.focus();}

		else if (pnombre.value.length < 3) {
			alert('Debes escribir el Nombre de tu pareja antes enviar la consulta.');pnombre.focus();}
		else if (!validaCampo(pnombre.value) || pnombre.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en el Nombre.');pnombre.focus();}
		else if (papellido1.value.length < 3) {
			alert('Debes escribir el 1er. Apellido de tu pareja antes enviar la consulta.');papellido1.focus();}
		else if (!validaCampo(papellido1.value) || papellido1.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en 1er. Apellido.');papellido1.focus();}
		else if (papellido2.value.length < 3) {
			alert('Debes escribir el 2 Apellido de tu pareja antes enviar la consulta.');papellido2.focus();}
		else if (!validaCampo(papellido2.value) || papellido2.value.length > 20) {
			alert('Datos incorrectos. Puede haber un error en 2 Apellido.');papellido2.focus();}

		else if (!validaDia(pday.value,pmonth.value,pyear.value)) {
			alert('Datos incorrectos. Error al introducir el Da');pday.focus();}
			
		else if (isEmpty(clave.value)){
			alert('Por favor introduzca la clave');clave.focus();}

		else{
		submit()};
	}
}


// ***********************************************************
// Funcin de retorno de cadena vaca
// ***********************************************************
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// ***********************************************************
// Funcin que comprueba si los caracteres introducidos estn en la variable    
// ***********************************************************
function validaCampo(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        // si el caracter en que estoy no aparece en la variable "caracteres",
        // entonces retornar falso
        if (caracteres.indexOf(c) == -1) return false;
    }
    return true;
}

// ***********************************************************
// Funcin que comprueba si los caracteres introducidos estn en la variable    
// ***********************************************************
function validaDia(dia,mes,ano)
{
if (dia > 28){
	if (mes=="1" || mes=="3" || mes=="5" || mes=="7" || mes=="8" || mes=="10" || mes=="12"){
		return true;
	}else{
		if (mes="2"){
			if (dia > 29){
			return false;
			}else{
				if ((ano % 4 == 0) && ((ano % 100 != 0) || (ano % 400 == 0))){
				return true;
				}else{
				return false;
				}
			}
		}else{
		return false;
		}
	}
}else{
return true;
}
}
// JavaScript fin ---------->
