function esDigito(sChr){
	var sCod = sChr.charCodeAt(0);
	return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt){
	var bOk = false;
	bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
	bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
	return bOk;
}

function finMes(oTxt){
	var nMes = parseInt(oTxt.value.substr(3, 2), 10);
	var nRes = 0;
	switch (nMes){
	case 1: nRes = 31; break;
	case 2: nRes = 29; break;
	case 3: nRes = 31; break;
	case 4: nRes = 30; break;
	case 5: nRes = 31; break;
	case 6: nRes = 30; break;
	case 7: nRes = 31; break;
	case 8: nRes = 31; break;
	case 9: nRes = 30; break;
	case 10: nRes = 31; break;
	case 11: nRes = 30; break;
	case 12: nRes = 31; break;
	}
	return nRes;
}

function valDia(oTxt){
	var bOk = false;
	var nDia = parseInt(oTxt.value.substr(0, 2), 10);
	bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
	return bOk;
}

function valMes(oTxt){
	var bOk = false;
	var nMes = parseInt(oTxt.value.substr(3, 2), 10);
	bOk = bOk || ((nMes >= 1) && (nMes <= 12));
	return bOk;
}

function valAno(oTxt){
	var bOk = true;
	var nAno = oTxt.value.substr(6);
	bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
	if (bOk){
		for (var i = 0; i < nAno.length; i++){
			bOk = bOk && esDigito(nAno.charAt(i));
		}
	}
	return bOk;
}

function valFecha(oTxt){
	var bOk = true;
	if (oTxt.value != ""){
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
			if (!bOk){
			alert("La Fecha es incorrecta");
			oTxt.select();
			}
	}
}
function validadia(field){
	dia1= field.value;
	if(dia1!=""){
		if(dia1>=1 && dia1<=31){
		}else{
			alert("El día es incorrecto verifique");
			field.select();
		}
	}
}
function validames(field){
	mes1= field.value;
	if(mes1!=""){
		if(mes1>=1 && mes1<=12){
		}else{
			alert("El mes es incorrecto verifique");
			field.select();
		}
	}
}
function validaano(field){
	ano1= field.value;
	if(ano1!=""){
		if(ano1.length==4){
		}else{
			alert("El año es incorrecto verifique");
			field.select();
		}
	}
}
function validadni(field){
	dni1= field.value;
	if(dni1==""){
	}else{
		if(dni1.length==8){
		}else{
			alert("El DNI debe contener 8 dígitos");
			field.select();
		}	
	}
}
function validaano1(field){
	ano2= field.value;
	if(ano2==""){
	}else{
	today = new Date();
	year1  = today.getYear();
	year1=year1+1;
		if(ano2.length==4){
			if(ano2>=1960 && ano2<=year1){
			}else{
				alert("El año debe debe de ser de 1960 a "+year1+"");		
				field.select();
			}
		}else{
			alert("El año debe de tener 4 dígitos");
			field.select();
		}
	}

}

/*----------valida placa----------*/
function valPlaca(txt)
{       e=event	
			tecla = (document.all) ? e.keyCode : e.which;
			if ((tecla < 48 || tecla > 57) && (tecla < 65 || tecla > 122) && (tecla!=45))
			{return false}
			if (tecla >= 91 && tecla <= 96){return false}
			cade=txt.value;
			valor=cade.toUpperCase();
			valor=valor.replace("Ñ","N");
			valor=valor.replace("Á","A");
			valor=valor.replace("É","E");
			valor=valor.replace("Í","I");
			valor=valor.replace("Ó","O");												
			valor=valor.replace("Ú","U");
			txt.value=valor
	}
/*---------------*/

<!---Solo formato2--->
//10/02/2007
	function valFecha2(e,txt) {
        pos=posicionCursor(txt)
		tecla = (document.all) ? e.keyCode : e.which;
		if(pos==2)
		{	if (tecla!=47) return false}
		else if(pos==5)
		{	if (tecla!=47) return false}

		else
		{	if (tecla<48 || tecla>57) return false	
		}
    }
<!----->	

<!---Devuelve la posicion del cursor en una caja de texto--->
function posicionCursor(elemento)
{
       var tb = document.getElementById(elemento)
        var cursor = -1;
        
        // IE
        if (document.selection && (document.selection != 'undefined'))
        {
            var _range = document.selection.createRange();
            var contador = 0;
            while (_range.move('character', -1))
                contador++;
            cursor = contador;
        }
       // FF
        else if (tb.selectionStart >= 0)
            cursor = tb.selectionStart;
    
       return cursor;
}
<!----->	

<!---Envia al hacer enter---->
function enter(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13){
envia();
return false;
}
else
return true;
}
<!------>

<!---Solo telefonos--->
	function fNumeros(e,txt) {
        tecla = (document.all) ? e.keyCode : e.which;
        if ((tecla<48 || tecla>57) && tecla!=42 && tecla!=35) return false;
    }
<!----->

<!---funcion TRIM-->
function trim(cadena)
{	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	return cadena;
}
<!----->

<!---deshabilita campos--->
function deshabilita(cc,frm)
{	form1=document.getElementById(frm)
	i=form1.length - cc;
	for(j=0;j<i;j++)
	{	form1[j].disabled=true;}
}
<!----->
<!---Quita mayusculas acentos y enes--->
/*	function formato3(txt)
	{		cade=document.getElementById(txt).value
			posi=posicionCursor(txt)
			valor=cade.toUpperCase();
			valor=valor.replace("Ñ","N")
			valor=valor.replace("Á","A")
			valor=valor.replace("É","E")
			valor=valor.replace("Í","I")
			valor=valor.replace("Ó","O")												
			valor=valor.replace("Ú","U")
			document.getElementById(txt).value=valor
			if ((event.shiftKey!=1))
			{ponCursorEnPos(posi,txt)}
	}*/
	function formato3(txt)
	{		cade=document.getElementById(txt).value
			//posi=posicionCursor(txt)
			valor=cade.toUpperCase();
			valor=valor.replace("Ñ","N")
			valor=valor.replace("Á","A")
			valor=valor.replace("É","E")
			valor=valor.replace("Í","I")
			valor=valor.replace("Ó","O")												
			valor=valor.replace("Ú","U")
			document.getElementById(txt).value=valor
			/*if ((event.shiftKey!=1))
			{ponCursorEnPos(posi,txt)}*/
	}

<!----->

<!---Quita minusculas acentos y enes--->
	function formato4(txt)
	{       cade=document.getElementById(txt).value
			valor=cade.toLowerCase();
			valor=valor.replace("ñ","n")
			valor=valor.replace("á","a")
			valor=valor.replace("é","e")
			valor=valor.replace("í","i")
			valor=valor.replace("ó","o")												
			valor=valor.replace("ú","u")
			document.getElementById(txt).value=valor
	}
<!----->

<!---pone cursor en posicion pos--->
function ponCursorEnPos(pos,caja){ 
	laCaja=document.getElementById(caja)
	if(typeof document.selection != 'undefined' && document.selection){ 
		var tex=laCaja.value;
        document.getElementById(caja).value=''; 
       // forzar_focus();
        var str = document.selection.createRange(); 
        document.getElementById(caja).value=tex;
        str.move("character", pos); 
        str.moveEnd("character", 0); 
        str.select();
    }
    else if(typeof laCaja.selectionStart != 'undefined'){ 
        laCaja.setSelectionRange(pos,pos);//forzar_focus();
    }

} 
<!----->	
<!---Solo decimales--->
	function decimales(e,txt) {
        tecla = (document.all) ? e.keyCode : e.which;
        if ((tecla<48 || tecla>57) && tecla!=46) return false
        if (tecla == 46 && txt.indexOf('.')!=-1) return false;
    }
<!----->

<!---Solo numeros--->
	var nav4 = window.Event ? true : false;
	function acceptNum(evt){ 
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 	
	var key = nav4 ? evt.which : evt.keyCode; 
	return (key <= 13 || (key >= 48 && key <= 57));
	}
	
	<!----->
	function conMayusculas(field) { 
            field.value = field.value.toUpperCase() 
	}
	function conMinusculas(field) { 
            field.value = field.value.toLowerCase() 
	}	