// JavaScript Document

function checkFormatoSoloLetras(obj)

{

	var nombre = obj.name;



	var valor = obj.value;



	var total = valor.length;



	var temp = "";



	var i;

	

	for(i=0;i<=total;i++)

	{	

		if(valor.charCodeAt(i)< 32)			

			obj.value=temp;	

		else

		if(valor.charCodeAt(i)> 32 && valor.charCodeAt(i)< 65)			

			obj.value=temp;	

		else			

		if(valor.charCodeAt(i) > 90 && valor.charCodeAt(i) < 97 )				

			obj.value=temp;		

		else	

		if(valor.charCodeAt(i)> 122)				

			obj.value=temp;		

	

		temp+= valor.charAt(i);		

	}

}



function checkFormatoSoloNumeros(obj)

{

	var nombre = obj.name;



	var valor = obj.value;



	var total = valor.length;



	var temp = "";



	var i;

	

	for(i=0;i<=total;i++)

	{	

		if(valor.charCodeAt(i)< 48)		

			obj.value=temp;

		else

		if(valor.charCodeAt(i)> 57 )			

			obj.value=temp;	



		temp+= valor.charAt(i);

	}

}



function emailCheck(emailStr) 

{

	/* Verificar si el email tiene el formato user@dominio. */



	var emailPat=/^(.+)@(.+)$/



	



	/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */



	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"



	



	/* Verifica los caracteres que son válidos en una dirección de email */



	var validChars="\[^\\s" + specialChars + "\]"



	



	var quotedUser="(\"[^\"]*\")"



	



	/* Verifica si la dirección de email está representada con una dirección IP Válida */



	



	



	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/



	



	/* Verificar caracteres inválidos */



	



	var atom=validChars + '+'



	var word="(" + atom + "|" + quotedUser + ")"



	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")



	/*	domain, as opposed to ipDomainPat, shown above. */



	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")



	



	



	var matchArray=emailStr.match(emailPat)



	if (matchArray==null) 



	{



		alert("Formato de Email incorrecto.")



		return false



	}



	var user=matchArray[1]



	var domain=matchArray[2]



	



	// Si el user "user" es valido 



	if (user.match(userPat)==null) 



	{



		// Si no



		alert("El nombre de usuario no es valido.")



		return false



	}



	



	var fullDomain = domain.split(".");

	



	/* Si la dirección IP es válida */



	var IPArray=domain.match(ipDomainPat)



	if (IPArray!=null) 



	{



			for (var i=1;i<=4;i++) 



			{



				if (IPArray[i]>255) 



				{



				alert("IP de destino invalida")



				return false



				}



			}



		return true



	}



	



	var domainArray=domain.match(domainPat)



	if (domainArray==null) 



	{



		alert("El dominio de su email no es valido.")



		return false



	}



	



	var atomPat=new RegExp(atom,"g")



	var domArr=domain.match(atomPat)



	var len=domArr.length



	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 



	{	



		alert("La direccion debe tener 3 letras si es .'com' o 2 si en de algún pais.")



		return false



	}



	



	if (len<2) 



	{



		var errStr="La direccion es erronea"



		alert(errStr)



		return false



	}



	



	// La dirección de email ingresada es Válida



	return true;	

}









//validacion formulario despacho..php






